|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +# where to put generated libraries |
| 19 | +set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/tools") |
| 20 | + |
| 21 | +# where to put generated binaries |
| 22 | +set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/tools") |
| 23 | + |
| 24 | +# 编译proto文件 |
| 25 | +execute_process( |
| 26 | + COMMAND make clean -C ${CMAKE_CURRENT_SOURCE_DIR}/proto |
| 27 | + RESULT_VARIABLE CLEAN_RESULT |
| 28 | +) |
| 29 | + |
| 30 | +execute_process( |
| 31 | + COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/proto |
| 32 | + RESULT_VARIABLE MAKE_RESULT |
| 33 | +) |
| 34 | + |
| 35 | +if(NOT ${MAKE_RESULT} EQUAL 0) |
| 36 | + message(FATAL_ERROR "Failed to compile proto files") |
| 37 | +endif() |
| 38 | + |
| 39 | +# 打印当前源代码目录 |
| 40 | +message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}") |
| 41 | + |
| 42 | +# 查找生成的proto文件 |
| 43 | +file(GLOB PROTO_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/build/proto/*.pb.cc") |
| 44 | +file(GLOB PROTO_HDRS "${CMAKE_CURRENT_SOURCE_DIR}/build/proto/*.pb.h") |
| 45 | + |
| 46 | +# 打印PROTO_SRCS和PROTO_HDRS |
| 47 | +message(STATUS "PROTO_SRCS: ${PROTO_SRCS}") |
| 48 | +message(STATUS "PROTO_HDRS: ${PROTO_HDRS}") |
| 49 | + |
| 50 | +# 添加 file_cache_microbench 可执行文件 |
| 51 | +add_executable(file_cache_microbench |
| 52 | + file_cache_microbench.cpp |
| 53 | + ${PROTO_SRCS} |
| 54 | +) |
| 55 | + |
| 56 | +# 添加proto生成文件的包含路径 |
| 57 | +target_include_directories(file_cache_microbench PRIVATE |
| 58 | + ${CMAKE_CURRENT_SOURCE_DIR}/build/proto |
| 59 | +) |
| 60 | + |
| 61 | +# 链接所需的库 |
| 62 | +target_link_libraries(file_cache_microbench |
| 63 | + ${DORIS_LINK_LIBS} |
| 64 | + protobuf |
| 65 | +) |
| 66 | + |
| 67 | +# 安装规则 |
| 68 | +install(TARGETS file_cache_microbench DESTINATION ${OUTPUT_DIR}/lib/) |
0 commit comments