Browse Source

2024-05-09

master
xiemingxian 1 year ago
parent
commit
52732ed07f
4 changed files with 34 additions and 20 deletions
  1. +1
    -4
      CMakeLists.txt
  2. +13
    -8
      cmake-local/gflags.cmake
  3. +12
    -3
      cmake-local/glog.cmake
  4. +8
    -5
      cmake-local/openfst.cmake

+ 1
- 4
CMakeLists.txt

@ -14,10 +14,7 @@ set(Red "${Esc}[31m")
include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
set(third_party_libraries)
message(STATUS 111)
set(LIB_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib_files)
set(LIB_BASE_DIR /root/projects/temp_xiaoke/asr_runtime/lib_files)
set(FETCHCONTENT_BASE_DIR ${LIB_BASE_DIR})
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-local)

+ 13
- 8
cmake-local/gflags.cmake

@ -1,12 +1,17 @@
#FetchContent_Declare(gflags
# SOURCE_DIR ${LIB_BASE_DIR}/gflags-src)
#FetchContent_MakeAvailable(gflags)
#
#include_directories(${gflags_BINARY_DIR}/include)
set(GFLAGS_ROOT_DIR ${LIB_BASE_DIR}/gflags-src)
set(GFLAGS_BUILD_DIR ${LIB_BASE_DIR}/gflags-build)
if(NOT EXISTS ${GLOG_BUILD_DIR})
execute_process(
COMMAND mkdir ${GLOG_BUILD_DIR} && cmake -S ${GLOG_ROOT_DIR} -B ${GLOG_BUILD_DIR}
WORKING_DIRECTORY ${LIB_BASE_DIR})
execute_process(
COMMAND cmake --build . -j4
WORKING_DIRECTORY ${GLOG_BUILD_DIR})
endif()
set(GFLAGS_ROOT_DIR ${LIB_BASE_DIR}/gflags-build)
find_package(gflags REQUIRED CONFIG HINTS ${GFLAGS_ROOT_DIR})
set(GFLAGS_INCLUDE_DIR ${LIB_BASE_DIR}/gflags-build/include)
list(APPEND third_party_libraries gflags)
list(APPEND third_party_libraries gflags)
message(STATUS gflags_FOUND)

+ 12
- 3
cmake-local/glog.cmake

@ -1,10 +1,19 @@
#find_package(glog REQUIRED)
#list(APPEND third_party_libraries glog::glog)
#/usr/bin clion
set(GLOG_ROOT_DIR /root/projects/temp_xiaoke/asr_runtime/lib_files/glog-build)
find_package(glog REQUIRED CONFIG PATHS ${GLOG_ROOT_DIR})
set(GLOG_ROOT_DIR ${LIB_BASE_DIR}/glog-src)
set(GLOG_BUILD_DIR ${LIB_BASE_DIR}/glog-build)
if(NOT EXISTS ${GLOG_BUILD_DIR})
execute_process(
COMMAND mkdir ${GLOG_BUILD_DIR} && cmake -S ${GLOG_ROOT_DIR} -B ${GLOG_BUILD_DIR}
WORKING_DIRECTORY ${LIB_BASE_DIR})
execute_process(
COMMAND cmake --build . -j4
WORKING_DIRECTORY ${GLOG_BUILD_DIR})
endif()
include_directories(GLOG_BUILD_DIR)
set(GLOG_INCLUDE_DIR ${GLOG_ROOT_DIR}/include)
# glog::glog is imported target
list(APPEND third_party_libraries glog)

+ 8
- 5
cmake-local/openfst.cmake

@ -1,6 +1,6 @@
# We can't build glog with gflags, unless gflags is pre-installed.
# If build glog with pre-installed gflags, there will be conflict.
message(STATUS "${BoldGreen}CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}${ColourReset}")
set(openfst_BUILD "${LIB_BASE_DIR}/openfst-build")
if(NOT EXISTS ${openfst_BUILD})
@ -24,13 +24,14 @@ endif()
# We can't build glog with gflags, unless gflags is pre-installed.
# If build glog with pre-installed gflags, there will be conflict.
# gflagsglog/usr/lib/x86_64-linux-gnu
find_package(gflags)
include(gflags)
if(TARGET gflags)
message(STATUS "${BoldGreen}TARGET: ${gflags_FOUND}${ColourReset}")
message(STATUS "${BoldGreen}Find Package gflags: ${gflags_FOUND}${ColourReset}")
set_target_properties(gflags PROPERTIES INTERFACE_COMPILE_OPTIONS "-fPIC")
endif()
set(WITH_GFLAGS OFF CACHE BOOL "whether build glog with gflags" FORCE)
include(cmake-local/glog.cmake)
find_package(glog)
message(STATUS "${BoldGreen}Find Package glog: ${glog_FOUND}${ColourReset}")
# cmake
if(NOT GRAPH_TOOLS)
set(HAVE_BIN OFF CACHE BOOL "Build the fst binaries" FORCE)
@ -52,9 +53,11 @@ FetchContent_Declare(openfst
FetchContent_MakeAvailable(openfst)
include_directories(${LIB_BASE_DIR}/openfst-src/src/include)
message(STATUS "${BoldGreen}openfst_BINARY_DIR: ${openfst_BINARY_DIR}${ColourReset}")
add_dependencies(fst gflags glog)
add_dependencies(fst gflags glog::glog)
target_link_libraries(fst PUBLIC gflags_nothreads_static glog)
list(APPEND third_party_libraries fst)

Loading…
Cancel
Save