-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix w2l@anywhere inference build (#930)
Summary: - Fix build for inference pipeline Pull Request resolved: #930 Differential Revision: D25783104 Pulled By: vineelpratap fbshipit-source-id: a0024f46ffb335d7cdc83ce0700a889491bc7228
- Loading branch information
1 parent
64e54f8
commit 5888ee8
Showing
42 changed files
with
566 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
recipes/streaming_convnets/inference/cmake/BuildGoogleTest.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
cmake_minimum_required(VERSION 3.10.0) | ||
|
||
include(ExternalProject) | ||
|
||
set(gtest_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/googletest/src/googletest/googletest/include) | ||
set(gtest_URL https://github.com/google/googletest.git) | ||
set(gtest_BUILD ${CMAKE_CURRENT_BINARY_DIR}/googletest/) | ||
set(gtest_TAG 703bd9caab50b139428cea1aaff9974ebee5742e) # release 1.10.0 | ||
|
||
if (NOT TARGET gtest) | ||
# Download googletest | ||
ExternalProject_Add( | ||
gtest | ||
PREFIX googletest | ||
GIT_REPOSITORY ${gtest_URL} | ||
GIT_TAG ${gtest_TAG} | ||
BUILD_IN_SOURCE 1 | ||
BUILD_COMMAND ${CMAKE_COMMAND} --build . | ||
INSTALL_COMMAND "" | ||
CMAKE_CACHE_ARGS | ||
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} | ||
-DCMAKE_BUILD_TYPE:STRING=Release | ||
-DBUILD_GMOCK:BOOL=ON | ||
-DBUILD_GTEST:BOOL=ON | ||
-Dgtest_force_shared_crt:BOOL=OFF | ||
) | ||
endif () | ||
|
||
ExternalProject_Get_Property(gtest source_dir) | ||
set(GTEST_SOURCE_DIR ${source_dir}) | ||
ExternalProject_Get_Property(gtest binary_dir) | ||
set(GTEST_BINARY_DIR ${binary_dir}) | ||
|
||
if (BUILD_SHARED_LIBS) | ||
set(LIB_TYPE SHARED) | ||
else() | ||
set(LIB_TYPE STATIC) | ||
endif() | ||
|
||
# Library and include dirs | ||
set(GTEST_LIBRARIES | ||
"${GTEST_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${CMAKE_${LIB_TYPE}_LIBRARY_PREFIX}gtest${CMAKE_${LIB_TYPE}_LIBRARY_SUFFIX}" | ||
) | ||
set(GTEST_LIBRARIES_MAIN | ||
"${GTEST_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${CMAKE_${LIB_TYPE}_LIBRARY_PREFIX}gtest_main${CMAKE_${LIB_TYPE}_LIBRARY_SUFFIX}" | ||
) | ||
set(GMOCK_LIBRARIES | ||
"${GTEST_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${CMAKE_${LIB_TYPE}_LIBRARY_PREFIX}gmock${CMAKE_${LIB_TYPE}_LIBRARY_SUFFIX}" | ||
) | ||
set(GMOCK_LIBRARIES_MAIN | ||
"${GTEST_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${CMAKE_${LIB_TYPE}_LIBRARY_PREFIX}gmock_main${CMAKE_${LIB_TYPE}_LIBRARY_SUFFIX}" | ||
) | ||
|
||
set(GTEST_INCLUDE_DIRS ${GTEST_SOURCE_DIR}/googletest/include) | ||
set(GMOCK_INCLUDE_DIRS ${GTEST_SOURCE_DIR}/googlemock/include) | ||
# Make dirs so this can be used as an interface include directory | ||
file(MAKE_DIRECTORY ${GTEST_INCLUDE_DIRS}) | ||
file(MAKE_DIRECTORY ${GMOCK_INCLUDE_DIRS}) | ||
|
||
add_library(GTest::gtest ${LIB_TYPE} IMPORTED) | ||
add_library(GTest::gtest_main ${LIB_TYPE} IMPORTED) | ||
add_library(GTest::gmock ${LIB_TYPE} IMPORTED) | ||
add_library(GTest::gmock_main ${LIB_TYPE} IMPORTED) | ||
|
||
set_target_properties(GTest::gtest PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS} | ||
IMPORTED_LOCATION ${GTEST_LIBRARIES} | ||
) | ||
set_target_properties(GTest::gtest_main PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS} | ||
IMPORTED_LOCATION ${GTEST_LIBRARIES_MAIN} | ||
) | ||
set_target_properties(GTest::gmock PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${GMOCK_INCLUDE_DIRS} | ||
IMPORTED_LOCATION ${GMOCK_LIBRARIES} | ||
) | ||
set_target_properties(GTest::gmock_main PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${GMOCK_INCLUDE_DIRS} | ||
IMPORTED_LOCATION ${GMOCK_LIBRARIES_MAIN} | ||
) |
51 changes: 51 additions & 0 deletions
51
recipes/streaming_convnets/inference/cmake/BuildKenlm.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
cmake_minimum_required(VERSION 3.10.0) | ||
|
||
# Required for KenLM to read ARPA files in compressed format | ||
find_package(LibLZMA REQUIRED) | ||
find_package(BZip2 REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
|
||
include(ExternalProject) | ||
|
||
set(kenlm_TEMP_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/extern/kenlm) | ||
set(kenlm_URL https://github.com/kpu/kenlm.git) | ||
set(kenlm_BUILD ${CMAKE_CURRENT_BINARY_DIR}/kenlm) | ||
set(kenlm_TAG 4a277534fd33da323205e6ec256e8fd0ff6ee6fa) | ||
|
||
if (NOT TARGET kenlm) | ||
# Download kenlm | ||
ExternalProject_Add( | ||
kenlm | ||
PREFIX kenlm | ||
GIT_REPOSITORY ${kenlm_URL} | ||
GIT_TAG ${kenlm_TAG} | ||
BUILD_IN_SOURCE 1 | ||
BUILD_COMMAND ${CMAKE_COMMAND} --build . | ||
CMAKE_CACHE_ARGS | ||
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} | ||
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} | ||
-DCMAKE_INSTALL_PREFIX:PATH=${kenlm_TEMP_INSTALL_DIR} | ||
) | ||
endif () | ||
|
||
# Install the install executed at build time | ||
install(DIRECTORY ${kenlm_TEMP_INSTALL_DIR}/include DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
install(DIRECTORY ${kenlm_TEMP_INSTALL_DIR}/lib DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
install(DIRECTORY ${kenlm_TEMP_INSTALL_DIR}/bin DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
|
||
if (BUILD_SHARED_LIBS) | ||
set(LIB_TYPE SHARED) | ||
else() | ||
set(LIB_TYPE STATIC) | ||
endif() | ||
|
||
# Library and include dirs | ||
set(KENLM_LIBRARIES | ||
"${kenlm_TEMP_INSTALL_DIR}/lib/${CMAKE_${LIB_TYPE}_LIBRARY_PREFIX}kenlm${CMAKE_${LIB_TYPE}_LIBRARY_SUFFIX}" | ||
"${kenlm_TEMP_INSTALL_DIR}/lib/${CMAKE_${LIB_TYPE}_LIBRARY_PREFIX}kenlm_util${CMAKE_${LIB_TYPE}_LIBRARY_SUFFIX}" | ||
${LIBLZMA_LIBRARIES} | ||
${BZIP2_LIBRARIES} | ||
${ZLIB_LIBRARIES} | ||
) | ||
set(KENLM_INCLUDE_DIRS "${kenlm_TEMP_INSTALL_DIR}/include") | ||
set(KENLM_INCLUDE_DIRS_LM "${kenlm_TEMP_INSTALL_DIR}/include/kenlm") |
Oops, something went wrong.