Ver Fonte

添加自功能模块文件

LiuZe há 10 meses atrás
pai
commit
a6dd5d0a82
3 ficheiros alterados com 98 adições e 0 exclusões
  1. 55 0
      CMakeLists.txt
  2. 25 0
      project/CMakeLists.txt
  3. 18 0
      protoc.sh

+ 55 - 0
CMakeLists.txt

@@ -0,0 +1,55 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(AllProject)
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
+
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
+if (NOT DEFINED ${CMAKE_BUILD_TYPE} OR ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
+    add_definitions(-DETC_PATH="${CMAKE_SOURCE_DIR}/etc/")
+else ()
+    add_definitions(-DETC_PATH="${CMAKE_INSTALL_PREFIX}/etc/")
+endif ()
+
+set(CMAKE_BUILD_TYPE "Release")
+# 第三方库
+find_package(PkgConfig REQUIRED)
+
+# Don't search with REQUIRED as we can continue without gflags.
+find_package(gflags 2.2.0)
+if (gflags_FOUND)
+    if (TARGET gflags)
+        message("-- Found Google Flags (gflags) version ${gflags_VERSION}: ${gflags_DIR}")
+        message("-- Found Google Flags (gflags) version ${gflags_VERSION}: ${GFLAGS_LIBRARIES}")
+    else()
+        message("-- Detected version of gflags: ${gflags_VERSION} does not define "
+                "expected gflags CMake target which should be exported by gflags 2.2+. "
+                "Building without gflags.")
+        update_cache_variable(GFLAGS OFF)
+    endif()
+else (gflags_FOUND)
+    message("-- Did not find Google Flags (gflags), Building without gflags.")
+    update_cache_variable(GFLAGS OFF)
+endif (gflags_FOUND)
+find_package(Glog)
+
+find_package(PCL REQUIRED)
+find_package(Eigen3 REQUIRED)
+find_package(OpenCV REQUIRED)
+find_package(Protobuf CONFIG)
+include_directories(
+        ${CMAKE_SOURCE_DIR}/include
+)
+
+add_subdirectory(${CMAKE_SOURCE_DIR}/include/rabbitmq)
+add_subdirectory(${CMAKE_SOURCE_DIR}/include/thread)
+add_subdirectory(${CMAKE_SOURCE_DIR}/include/message)
+add_subdirectory(${CMAKE_SOURCE_DIR}/include/pahoc)
+#execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/protoc.sh ${CMAKE_CURRENT_LIST_DIR})
+
+if (EXISTS "${CMAKE_SOURCE_DIR}/project/CMakeLists.txt")
+    add_subdirectory(${CMAKE_SOURCE_DIR}/project)
+else ()
+    message("Can't find dir: " "${CMAKE_SOURCE_DIR}/project/CMakeLists.txt")
+endif ()

+ 25 - 0
project/CMakeLists.txt

@@ -0,0 +1,25 @@
+# 获取当前目录下的所有目录
+file(GLOB directories RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*)
+
+foreach(dir ${directories})
+    if (DEFINED ENABLE_PROJECT)
+        list(FIND ENABLE_PROJECT ${dir} PROJECT)
+        if(NOT PROJECT EQUAL -1)
+            if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
+                if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/CMakeLists.txt")
+                    add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${dir})
+                else ()
+                    message("Can't find dir: " "${CMAKE_SOURCE_DIR}/${dir}/CMakeLists.txt")
+                endif ()
+            endif ()
+        endif()
+    else()
+        if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
+            if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/CMakeLists.txt")
+                add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${dir})
+            else ()
+                message("Can't find dir: " "${CMAKE_SOURCE_DIR}/${dir}/CMakeLists.txt")
+            endif ()
+        endif ()
+    endif ()
+endforeach()

+ 18 - 0
protoc.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+
+files=($(find $1 -type f -name "*.proto"))
+paths=()
+filenames=()
+
+for file in ${files[@]}; do
+    path=$(dirname $file)
+    filename=$(basename $file)
+#    paths+=("$path")
+#    filenames+=("$filename#*.")
+    if [ "${filename#*.}" = "grpc.proto" ]; then
+        # 打印文件名
+        protoc -I="$path" $filename --cpp_out="$path" --grpc_out="$path" --plugin=protoc-gen-grpc=`which grpc_cpp_plugin`
+    elif [ "${filename#*.}" = "proto" ]; then
+        protoc -I="$path" $filename --cpp_out="$path"
+    fi
+done