diff --git a/CMakeLists.txt b/CMakeLists.txt index 14438ba..f3cdc3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") enable_testing() -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) if(DEFINED ENV{OPENFST_ROOT}) @@ -41,7 +41,7 @@ set(OPENFST_INCLUDES if(DYNAMIC_OPENFST) set(OPENFST_LIBRARIES - ${OPENFST_ROOT}/lib/libfst.so + ${OPENFST_ROOT}/lib/libfst${CMAKE_SHARED_LIBRARY_SUFFIX} ) else() set(OPENFST_LIBRARIES @@ -69,7 +69,7 @@ add_library(fstaligner-common third-party/inih/cpp/INIReader.cpp ) -list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/icu4c") # for Mac users +list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/icu4c" "/opt/homebrew/opt/icu4c@78" "/opt/homebrew/opt/icu4c") # for Mac users find_package(ICU REQUIRED COMPONENTS uc) target_link_libraries(fstaligner-common @@ -80,8 +80,16 @@ target_link_libraries(fstaligner-common ) add_subdirectory(third-party/jsoncpp) +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(jsoncpp_lib_static PRIVATE -Wno-implicit-int-float-conversion) +endif() add_subdirectory(third-party/catch2) +if(DYNAMIC_OPENFST) + set(CMAKE_BUILD_RPATH "${OPENFST_ROOT}/lib") + set(CMAKE_INSTALL_RPATH "${OPENFST_ROOT}/lib") +endif() + add_executable(fstalign src/main.cpp) include_directories(fstalign diff --git a/README.md b/README.md index 1fc3948..93404d5 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,28 @@ Finally, tests can be run using: make test ``` +### Building on macOS with OpenFST 1.8.x + +Homebrew's bundled `openfst` formula (in `openfst.rb`) provides 1.7.9 and conflicts +with `homebrew/core/openfst`. Build OpenFST 1.8.x from source instead: + +```bash +curl -L -O https://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.8.4.tar.gz +tar xzf openfst-1.8.4.tar.gz +cd openfst-1.8.4 +./configure --prefix="$HOME/opt/openfst-1.8.4" --disable-dependency-tracking +make -j$(sysctl -n hw.logicalcpu) install +``` + +Then build fstalign pointing at the new prefix: + +```bash +mkdir build && cd build +cmake .. -DOPENFST_ROOT="$HOME/opt/openfst-1.8.4" -DDYNAMIC_OPENFST=ON +make -j$(sysctl -n hw.logicalcpu) +make test +``` + ### Docker The fstalign docker image is hosted on Docker Hub and can be easily pulled and run: diff --git a/src/AdaptedComposition.cpp b/src/AdaptedComposition.cpp index 0d715a7..5cadf94 100644 --- a/src/AdaptedComposition.cpp +++ b/src/AdaptedComposition.cpp @@ -475,7 +475,7 @@ void AdaptedCompositionFst::SetSymbols(const fst::SymbolTable *symbols) { logger_->debug("{}:{} we created 2 vector of {} items", __FILE__, __LINE__, symbols->NumSymbols()); for (SymbolTableIterator siter(*symbols); !siter.Done(); siter.Next()) { - int64 sid = siter.Value(); + int64_t sid = siter.Value(); auto sym_tk = symbols->Find(sid); if (isSynonymLabel(sym_tk)) { diff --git a/src/AdaptedComposition.h b/src/AdaptedComposition.h index 7cc808a..c1297a1 100644 --- a/src/AdaptedComposition.h +++ b/src/AdaptedComposition.h @@ -19,8 +19,8 @@ using namespace std; typedef fst::Fst::StateId StateId; -typedef pair StatePair; -struct key_hash : public std::unary_function { +typedef pair StatePair; +struct key_hash { std::size_t operator()(const StatePair &k) const { return std::get<0>(k) ^ std::get<1>(k); } }; diff --git a/src/fstalign.cpp b/src/fstalign.cpp index 6c57fd1..b35d78b 100644 --- a/src/fstalign.cpp +++ b/src/fstalign.cpp @@ -35,7 +35,7 @@ class ReverseOLabelCompare { return std::forward_as_tuple(lhs.olabel, lhs.ilabel) > std::forward_as_tuple(rhs.olabel, rhs.ilabel); } - constexpr uint64 Properties(uint64 props) const { + constexpr uint64_t Properties(uint64_t props) const { return (props & kArcSortProperties) | kOLabelSorted | (props & kAcceptor ? kILabelSorted : 0); } }; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fe7964a..b20f244 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,18 +21,18 @@ target_link_libraries(fstalign_Test Threads::Threads) add_test(NAME fstalign_Test COMMAND $ - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/build) + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_executable(compose-tests compose-tests.cc) target_link_libraries(compose-tests Threads::Threads) add_test(NAME compose-tests COMMAND $ - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/build) + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_executable(fast-d-tests fast-d-tests.cc) target_link_libraries(fast-d-tests Threads::Threads) add_test(NAME fast-d-tests COMMAND $ - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/build) + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/third-party/strtk b/third-party/strtk index b887974..3718839 160000 --- a/third-party/strtk +++ b/third-party/strtk @@ -1 +1 @@ -Subproject commit b88797408e614ff5a127df12cc520bf41769ada6 +Subproject commit 3718839494679e223e796ff4f9be695394a87402