From a9b114cefeb21951254bc87d90719c359fbafdcc Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 7 May 2024 17:01:02 +0800 Subject: [PATCH] =?UTF-8?q?#=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- cmake-local/gflags.cmake | 13 +++++++++++-- cmake-local/glog.cmake | 8 +++++++- cmake-local/openfst.cmake | 20 ++++++++++++-------- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d45ad7..250118c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,5 +38,5 @@ endif() if(OPENFST) include(openfst) add_executable(fst_main "fst.cc") - target_link_libraries(fst_main ${third_party_libraries} dl) + target_link_libraries(fst_main PRIVATE ${third_party_libraries}) endif() diff --git a/cmake-local/gflags.cmake b/cmake-local/gflags.cmake index 6942454..db7a0e5 100644 --- a/cmake-local/gflags.cmake +++ b/cmake-local/gflags.cmake @@ -1,3 +1,12 @@ -find_package(gflags REQUIRED) +#FetchContent_Declare(gflags +# SOURCE_DIR ${LIB_BASE_DIR}/gflags-src) +#FetchContent_MakeAvailable(gflags) +# +#include_directories(${gflags_BINARY_DIR}/include) -list(APPEND third_party_libraries gflags) + +set(GFLAGS_ROOT_DIR ${LIB_BASE_DIR}/gflags-src) +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) \ No newline at end of file diff --git a/cmake-local/glog.cmake b/cmake-local/glog.cmake index be2663e..113d1ce 100644 --- a/cmake-local/glog.cmake +++ b/cmake-local/glog.cmake @@ -1,2 +1,8 @@ -find_package(glog REQUIRED) +#find_package(glog REQUIRED) +#list(APPEND third_party_libraries glog::glog) + +set(GLOG_ROOT_DIR ${LIB_BASE_DIR}/glog-src) +find_package(glog REQUIRED CONFIG HINTS ${GLOG_ROOT_DIR}) +set(GLOG_INCLUDE_DIR ${GLOG_ROOT_DIR}/include) +# glog::glog is imported target list(APPEND third_party_libraries glog::glog) \ No newline at end of file diff --git a/cmake-local/openfst.cmake b/cmake-local/openfst.cmake index 9c64e25..f6d5892 100644 --- a/cmake-local/openfst.cmake +++ b/cmake-local/openfst.cmake @@ -18,10 +18,15 @@ if(NOT EXISTS ${openfst_BUILD}) endif() # We can't build glog with gflags, unless gflags is pre-installed. # If build glog with pre-installed gflags, there will be conflict. +# gflags和glog现在被我安装到了系统盘下/usr/lib/x86_64-linux-gnu find_package(gflags) +if(TARGET gflags) + message(STATUS "${BoldGreen}TARGET: ${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) find_package(glog) - +# 下面这堆关键字是防止cmake出一堆无关的提示 if(NOT GRAPH_TOOLS) set(HAVE_BIN OFF CACHE BOOL "Build the fst binaries" FORCE) set(HAVE_SCRIPT OFF CACHE BOOL "Build the fstscript" FORCE) @@ -39,14 +44,13 @@ set(HAVE_SPECIAL OFF CACHE BOOL "Build special" FORCE) FetchContent_Declare(openfst SOURCE_DIR ${LIB_BASE_DIR}/openfst-src) -# FetchContent_MakeAvailable(openfst) -include_directories(${openfst_SOURCE_DIR}/src/include) -set(openfst_BINARY_DIR "${grpc_build_dir}/src/lib") -add_dependencies(fst glog::glog gflags) -list(APPEND third_party_libraries fst glog::glog gflags) +include_directories(${LIB_BASE_DIR}/openfst-src/src/include) +message(STATUS "${BoldGreen}openfst_BINARY_DIR: ${openfst_BINARY_DIR}${ColourReset}") -#list(APPEND third_party_libraries ) +add_dependencies(fst gflags_nothreads_static glog::glog) +#set_target_properties(fst PROPERTIES COMPILE_FLAGS "-fPIC") +target_link_libraries(fst PUBLIC gflags_nothreads_static glog) -# \ No newline at end of file +list(APPEND third_party_libraries fst) \ No newline at end of file