rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ifplu...@apache.org
Subject [rocketmq-client-cpp] branch re_dev updated: refactor: cmake scripts
Date Fri, 26 Mar 2021 07:45:10 GMT
This is an automated email from the ASF dual-hosted git repository.

ifplusor pushed a commit to branch re_dev
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git


The following commit(s) were added to refs/heads/re_dev by this push:
     new eca5835  refactor: cmake scripts
eca5835 is described below

commit eca58359185744d041d4835d06774d6e600c3fbe
Author: James Yin <ywhjames@hotmail.com>
AuthorDate: Fri Mar 26 14:34:14 2021 +0800

    refactor: cmake scripts
---
 CMakeLists.txt                  | 238 ++++++++++++++++++++--------------------
 cmake/BundleStaticLibrary.cmake |  83 ++++++++------
 cmake/FindJsoncpp.cmake         |  93 ++++++++--------
 cmake/FindLibevent.cmake        | 226 ++++++++++++++++++++------------------
 project/CMakeLists.txt          | 105 +++++++++---------
 test/CMakeLists.txt             | 112 ++++++++++---------
 6 files changed, 447 insertions(+), 410 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e39910e..33a1d4d 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,59 +16,59 @@
 cmake_minimum_required(VERSION 2.8)
 
 # CMake complains if we don't have this.
-if (COMMAND cmake_policy)
-    cmake_policy(SET CMP0003 NEW)
-endif ()
-
-# We're escaping quotes in the Windows version number, because
-# for some reason CMake won't do it at config version 2.4.7
-# It seems that this restores the newer behaviour where define
-# args are not auto-escaped.
-if (COMMAND cmake_policy)
-    cmake_policy(SET CMP0005 NEW)
-endif ()
+if(COMMAND cmake_policy)
+  cmake_policy(SET CMP0003 NEW)
+endif()
+
+# We're escaping quotes in the Windows version number, because for some reason
+# CMake won't do it at config version 2.4.7 It seems that this restores the
+# newer behaviour where define args are not auto-escaped.
+if(COMMAND cmake_policy)
+  cmake_policy(SET CMP0005 NEW)
+endif()
 
 # First, declare project (important for prerequisite checks).
 project(rocketmq-client-cpp)
 
-if (NOT CMAKE_BUILD_TYPE)
-    set(CMAKE_BUILD_TYPE "Release")
-endif ()
-if (NOT CMAKE_CONFIGURATION_TYPES)
-    set(CMAKE_CONFIGURATION_TYPES "Release")
-endif ()
+if(NOT CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE "Release")
+endif()
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  set(CMAKE_CONFIGURATION_TYPES "Release")
+endif()
 
 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
 
 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
 set(CMAKE_VERBOSE_MAKEFILE 1)
 
-if (APPLE)
-    set(CMAKE_MACOSX_RPATH 1)
-endif (APPLE)
+if(APPLE)
+  set(CMAKE_MACOSX_RPATH 1)
+endif(APPLE)
 
 # put binaries in a different dir to make them easier to find.
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
 set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
 
 # Find dependencies
-#find_package(spdlog REQUIRED)
-if (NOT spdlog_FOUND)
-    include_directories(${CMAKE_SOURCE_DIR}/bin/include)
-endif ()
-
-option(Libevent_USE_STATIC_LIBS "only find libevent static libs" OFF) # only find static
libs
-if (NOT LIBEVENT_ROOT)
-    set(LIBEVENT_ROOT ${CMAKE_SOURCE_DIR}/bin)
-endif ()
+
+# find_package(spdlog REQUIRED)
+if(NOT spdlog_FOUND)
+  include_directories(${CMAKE_SOURCE_DIR}/bin/include)
+endif()
+
+option(Libevent_USE_STATIC_LIBS "only find libevent static libs" OFF)
+if(NOT LIBEVENT_ROOT)
+  set(LIBEVENT_ROOT ${CMAKE_SOURCE_DIR}/bin)
+endif()
 find_package(Libevent 2.0.21 REQUIRED)
-message(STATUS "** LIBEVENT_INCLUDE_DIR: ${LIBEVENT_INCLUDE_DIR}")
+message(STATUS "** LIBEVENT_INCLUDE_DIRS: ${LIBEVENT_INCLUDE_DIRS}")
 message(STATUS "** LIBEVENT_LIBRARIES: ${LIBEVENT_LIBRARIES}")
 
-option(JSONCPP_USE_STATIC_LIBS "only find jsoncpp static libs" OFF) # only find static libs
-if (NOT JSONCPP_ROOT)
-    set(JSONCPP_ROOT ${CMAKE_SOURCE_DIR}/bin)
-endif ()
+option(JSONCPP_USE_STATIC_LIBS "only find jsoncpp static libs" OFF)
+if(NOT JSONCPP_ROOT)
+  set(JSONCPP_ROOT ${CMAKE_SOURCE_DIR}/bin)
+endif()
 find_package(Jsoncpp 0.10.6 REQUIRED)
 message(STATUS "** JSONCPP_INCLUDE_DIRS: ${JSONCPP_INCLUDE_DIRS}")
 message(STATUS "** JSONCPP_LIBRARIES: ${JSONCPP_LIBRARIES}")
@@ -76,97 +76,93 @@ message(STATUS "** JSONCPP_LIBRARIES: ${JSONCPP_LIBRARIES}")
 # Set compile options
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
-CHECK_C_COMPILER_FLAG("-std=c99" COMPILER_SUPPORTS_C99)
-CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-if (COMPILER_SUPPORTS_C99 AND COMPILER_SUPPORTS_CXX11)
-    if (NOT (CMAKE_VERSION VERSION_LESS "3.1"))
-        set(CMAKE_C_STANDARD 99)
-        set(CMAKE_CXX_STANDARD 11)
-        message(STATUS "** set CMAKE_C_STANDARD to 99")
-        message(STATUS "** set CMAKE_CXX_STANDARD to 11")
-    else ()
-        if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
-            set(C_STANDARD_FLAG "-std=gnu99")
-            set(CXX_STANDARD_FLAG "-std=gnu++11")
-        else ()
-            set(C_STANDARD_FLAG "-std=c99")
-            set(CXX_STANDARD_FLAG "-std=c++11")
-        endif ()
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_STANDARD_FLAG}")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAG}")
-        message(STATUS "** set CMAKE_C_FLAGS with ${C_STANDARD_FLAG}")
-        message(STATUS "** set CMAKE_CXX_FLAGS with ${CXX_STANDARD_FLAG}")
-    endif ()
-else ()
-    message(FATAL_ERROR "The compiler has no C99 or C++11 support.")
-endif ()
-
-if (WIN32)
-    add_definitions(-DWIN32 -DROCKETMQCLIENT_EXPORTS)
-    add_compile_options(/EHsc)
-    if (CMAKE_BUILD_TYPE EQUAL "Release")
-        add_compile_options(/MT)
-    else ()
-        add_compile_options(/MTd)
-    endif ()
-else ()
-    add_compile_options(-Wall
-        -Wno-deprecated
-        -fPIC
-        -fno-strict-aliasing
-        -Wno-unused-local-typedef
-        -Wno-expansion-to-defined)
-
-    if (CMAKE_BUILD_BITS EQUAL 32)
-        add_compile_options(-m32)
-    else () #not-condition
-        add_compile_options(-m64)
-    endif ()
-
-    # Declare deplibs, so we can use list in linker later. There's probably
-    # a more elegant way of doing this; with SCons, when you check for the
-    # lib, it is automatically passed to the linker.
-    set(deplibs)
-
-    # For some reason, the check_function_exists macro doesn't detect
-    # the inet_aton on some pure Unix platforms (e.g. sunos5). So we
-    # need to do a more detailed check and also include some extra deplibs.
-    list(APPEND deplibs dl)
-    list(APPEND deplibs pthread)
-    if (NOT APPLE)
-        list(APPEND deplibs rt)
-    endif ()
-    list(APPEND deplibs z)
-
-    option(CODE_COVERAGE "Enable coverage reporting" OFF)
-    if (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
-        # Add required flags (GCC & LLVM/Clang)
-        # Code Coverage Configuration
-        add_library(coverage_config INTERFACE)
-        target_compile_options(coverage_config INTERFACE
-                -O0        # no optimization
-                -g         # generate debug info
+check_c_compiler_flag("-std=c99" COMPILER_SUPPORTS_C99)
+check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
+if(COMPILER_SUPPORTS_C99 AND COMPILER_SUPPORTS_CXX11)
+  if(NOT (CMAKE_VERSION VERSION_LESS "3.1"))
+    set(CMAKE_C_STANDARD 99)
+    set(CMAKE_CXX_STANDARD 11)
+    message(STATUS "** set CMAKE_C_STANDARD to 99")
+    message(STATUS "** set CMAKE_CXX_STANDARD to 11")
+  else()
+    if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+      set(C_STANDARD_FLAG "-std=gnu99")
+      set(CXX_STANDARD_FLAG "-std=gnu++11")
+    else()
+      set(C_STANDARD_FLAG "-std=c99")
+      set(CXX_STANDARD_FLAG "-std=c++11")
+    endif()
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_STANDARD_FLAG}")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAG}")
+    message(STATUS "** set CMAKE_C_FLAGS with ${C_STANDARD_FLAG}")
+    message(STATUS "** set CMAKE_CXX_FLAGS with ${CXX_STANDARD_FLAG}")
+  endif()
+else()
+  message(FATAL_ERROR "The compiler has no C99 or C++11 support.")
+endif()
+
+if(WIN32)
+  add_definitions(-DWIN32 -DROCKETMQCLIENT_EXPORTS)
+  add_compile_options(/EHsc)
+  if(CMAKE_BUILD_TYPE EQUAL "Release")
+    add_compile_options(/MT)
+  else()
+    add_compile_options(/MTd)
+  endif()
+else()
+  add_compile_options(-Wall -Wno-deprecated -fPIC -fno-strict-aliasing
+                      -Wno-unused-local-typedef -Wno-expansion-to-defined)
+
+  if(CMAKE_BUILD_BITS EQUAL 32)
+    add_compile_options(-m32)
+  else() # not-condition
+    add_compile_options(-m64)
+  endif()
+
+  # Declare deplibs, so we can use list in linker later. There's probably a more
+  # elegant way of doing this; with SCons, when you check for the lib, it is
+  # automatically passed to the linker.
+  set(deplibs)
+
+  # For some reason, the check_function_exists macro doesn't detect the
+  # inet_aton on some pure Unix platforms (e.g. sunos5). So we need to do a more
+  # detailed check and also include some extra deplibs.
+  list(APPEND deplibs dl)
+  list(APPEND deplibs pthread)
+  if(NOT APPLE)
+    list(APPEND deplibs rt)
+  endif()
+  list(APPEND deplibs z)
+
+  option(CODE_COVERAGE "Enable coverage reporting" OFF)
+  if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+    # Add required flags (GCC & LLVM/Clang) Code Coverage Configuration
+    add_library(coverage_config INTERFACE)
+    target_compile_options(
+      coverage_config
+      INTERFACE -O0 # no optimization
+                -g # generate debug info
                 --coverage # sets all required flags
-                )
-        if (NOT (CMAKE_VERSION VERSION_LESS "3.13"))
-            target_link_options(coverage_config INTERFACE --coverage)
-        else ()
-            target_link_libraries(coverage_config INTERFACE --coverage)
-        endif ()
-        list(APPEND deplibs coverage_config)
-    endif (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
-
-    # add include dir for bsd (posix uses /usr/include/)
-    set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
-endif ()
+    )
+    if(NOT (CMAKE_VERSION VERSION_LESS "3.13"))
+      target_link_options(coverage_config INTERFACE --coverage)
+    else()
+      target_link_libraries(coverage_config INTERFACE --coverage)
+    endif()
+    list(APPEND deplibs coverage_config)
+  endif(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+
+  # add include dir for bsd (posix uses /usr/include/)
+  set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
+endif()
 
 add_subdirectory(libs)
 add_subdirectory(project)
 add_subdirectory(example)
 
 option(RUN_UNIT_TEST "RUN_UNIT_TEST" OFF)
-if (RUN_UNIT_TEST)
-    message(STATUS "** RUN_UNIT_TEST: Do execution testing")
-    enable_testing()
-    add_subdirectory(test)
-endif ()
+if(RUN_UNIT_TEST)
+  message(STATUS "** RUN_UNIT_TEST: Do execution testing")
+  enable_testing()
+  add_subdirectory(test)
+endif()
diff --git a/cmake/BundleStaticLibrary.cmake b/cmake/BundleStaticLibrary.cmake
index 04659db..c53d317 100644
--- a/cmake/BundleStaticLibrary.cmake
+++ b/cmake/BundleStaticLibrary.cmake
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
+#
 # ref: https://cristianadam.eu/20190501/bundling-together-static-libraries-with-cmake/
 
 set(STATIC_LIBRARY_REGEX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
@@ -50,7 +50,8 @@ function(bundle_static_library tgt_name bundled_tgt_name)
           _recursively_collect_dependencies(${dependency})
         endif()
       else()
-        string(REGEX MATCH ${STATIC_LIBRARY_REGEX} IS_STATIC_LIBRARY ${dependency})
+        string(REGEX MATCH ${STATIC_LIBRARY_REGEX} IS_STATIC_LIBRARY
+                     ${dependency})
         if(IS_STATIC_LIBRARY)
           list(APPEND static_libs ${dependency})
         endif()
@@ -69,42 +70,60 @@ function(bundle_static_library tgt_name bundled_tgt_name)
       ${LIBRARY_OUTPUT_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}${bundled_tgt_name}${CMAKE_STATIC_LIBRARY_SUFFIX}
   )
 
+  message(STATUS "Bundling static library: ${bundled_tgt_full_name}")
   if(CMAKE_CXX_COMPILER_ID MATCHES "^(AppleClang|Clang|GNU)$")
-    file(WRITE ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in
-         "CREATE ${bundled_tgt_full_name}\n")
+    if(APPLE)
+      find_program(LIB_TOOL libtool REQUIRED)
+
+      foreach(tgt IN LISTS static_libs)
+        if(TARGET ${tgt})
+          list(APPEND static_libs_full_names $<TARGET_FILE:${tgt}>)
+        else()
+          list(APPEND static_libs_full_names ${tgt})
+        endif()
+      endforeach()
+
+      add_custom_command(
+        OUTPUT ${bundled_tgt_full_name}
+        COMMAND ${LIB_TOOL} -no_warning_for_no_symbols -static -o
+                ${bundled_tgt_full_name} ${static_libs_full_names}
+        COMMENT "Bundling ${bundled_tgt_name}"
+        VERBATIM)
+    else()
+      file(WRITE ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in
+           "CREATE ${bundled_tgt_full_name}\n")
+
+      foreach(tgt IN LISTS static_libs)
+        if(TARGET ${tgt})
+          file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in
+               "ADDLIB $<TARGET_FILE:${tgt}>\n")
+        else()
+          file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in
+               "ADDLIB ${tgt}\n")
+        endif()
+      endforeach()
 
-    foreach(tgt IN LISTS static_libs)
-      if(TARGET ${tgt})
-        file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in
-             "ADDLIB $<TARGET_FILE:${tgt}>\n")
-      else()
-        file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in
-             "ADDLIB ${tgt}\n")
-      endif()
-    endforeach()
+      file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in "SAVE\n")
+      file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in "END\n")
 
-    file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in "SAVE\n")
-    file(APPEND ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in "END\n")
+      file(
+        GENERATE
+        OUTPUT ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri
+        INPUT ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in)
 
-    file(
-      GENERATE
-      OUTPUT ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri
-      INPUT ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri.in)
+      set(AR_TOOL ${CMAKE_AR})
+      if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
+        set(AR_TOOL ${CMAKE_CXX_COMPILER_AR})
+      endif()
 
-    set(ar_tool ${CMAKE_AR})
-    if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
-      set(ar_tool ${CMAKE_CXX_COMPILER_AR})
+      add_custom_command(
+        OUTPUT ${bundled_tgt_full_name}
+        COMMAND ${AR_TOOL} -M < ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri
+        COMMENT "Bundling ${bundled_tgt_name}"
+        VERBATIM)
     endif()
-
-    message(
-      STATUS "** Bundled static library: ${bundled_tgt_full_name}")
-    add_custom_command(
-      OUTPUT ${bundled_tgt_full_name}
-      COMMAND ${ar_tool} -M < ${CMAKE_BINARY_DIR}/${bundled_tgt_name}.mri
-      COMMENT "Bundling ${bundled_tgt_name}"
-      VERBATIM)
   elseif(MSVC)
-    find_program(lib_tool lib)
+    find_program(LIB_TOOL lib REQUIRED)
 
     foreach(tgt IN LISTS static_libs)
       list(APPEND static_libs_full_names $<TARGET_FILE:${tgt}>)
@@ -112,7 +131,7 @@ function(bundle_static_library tgt_name bundled_tgt_name)
 
     add_custom_command(
       OUTPUT ${bundled_tgt_full_name}
-      COMMAND ${lib_tool} /NOLOGO /OUT:${bundled_tgt_full_name}
+      COMMAND ${LIB_TOOL} /NOLOGO /OUT:${bundled_tgt_full_name}
               ${static_libs_full_names}
       COMMENT "Bundling ${bundled_tgt_name}"
       VERBATIM)
diff --git a/cmake/FindJsoncpp.cmake b/cmake/FindJsoncpp.cmake
index 4625ccf..b9a3ab3 100755
--- a/cmake/FindJsoncpp.cmake
+++ b/cmake/FindJsoncpp.cmake
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
+#
 # Find jsoncpp
 #
 # Find the jsoncpp includes and library
@@ -30,59 +30,58 @@
 #  JSONCPP_LIBRARIES, the libraries needed to use jsoncpp.
 
 # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
-if (JSONCPP_USE_STATIC_LIBS)
-    set(_jsoncpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES :${CMAKE_FIND_LIBRARY_SUFFIXES})
-    if (WIN32)
-        list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a)
-    else ()
-        set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
-    endif ()
-else ()
-    set(_jsoncpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES :${CMAKE_FIND_LIBRARY_SUFFIXES})
-    if (WIN32)
-        list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .dll .so)
-    elseif (APPLE)
-        set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
-    else ()
-        set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
-    endif ()
-endif ()
+if(JSONCPP_USE_STATIC_LIBS)
+  set(_jsoncpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES :${CMAKE_FIND_LIBRARY_SUFFIXES})
+  if(WIN32)
+    list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a)
+  else()
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
+  endif()
+else()
+  set(_jsoncpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES :${CMAKE_FIND_LIBRARY_SUFFIXES})
+  if(WIN32)
+    list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .dll .so)
+  elseif(APPLE)
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
+  else()
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
+  endif()
+endif()
 
 set(JSONCPP_INCLUDE_SEARCH_PATH /usr/local/include /usr/include)
 set(JSONCPP_LIBRARIES_SEARCH_PATH /usr/local/lib /usr/lib)
-if (JSONCPP_ROOT)
-    list(INSERT JSONCPP_INCLUDE_SEARCH_PATH 0 ${JSONCPP_ROOT}/include)
-    list(INSERT JSONCPP_LIBRARIES_SEARCH_PATH 0 ${JSONCPP_ROOT}/lib)
-endif ()
+if(JSONCPP_ROOT)
+  list(INSERT JSONCPP_INCLUDE_SEARCH_PATH 0 ${JSONCPP_ROOT}/include)
+  list(INSERT JSONCPP_LIBRARIES_SEARCH_PATH 0 ${JSONCPP_ROOT}/lib)
+endif()
 
-find_path(JSONCPP_INCLUDE_DIRS
-        NAMES json.h json/json.h
-        PATHS ${JSONCPP_INCLUDE_SEARCH_PATH}
-        PATH_SUFFIXES jsoncpp)
+find_path(
+  JSONCPP_JSON_DIR
+  NAMES json/json.h json.h
+  PATHS ${JSONCPP_INCLUDE_SEARCH_PATH}
+  PATH_SUFFIXES jsoncpp
+  NO_DEFAULT_PATH)
 
-find_library(JSONCPP_LIBRARIES
-        NAMES jsoncpp
-        PATHS ${JSONCPP_LIBRARIES_SEARCH_PATH})
+find_library(
+  JSONCPP_JSONCPP_LIBRARY
+  NAMES jsoncpp
+  PATHS ${JSONCPP_LIBRARIES_SEARCH_PATH}
+  NO_DEFAULT_PATH)
 
-if (JSONCPP_LIBRARIES AND JSONCPP_INCLUDE_DIRS)
-    set(JSONCPP_FOUND "YES")
-else (JSONCPP_LIBRARIES AND JSONCPP_INCLUDE_DIRS)
-    set(JSONCPP_FOUND "NO")
-endif (JSONCPP_LIBRARIES AND JSONCPP_INCLUDE_DIRS)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Jsoncpp REQUIRED_VARS JSONCPP_JSON_DIR
+                                                        JSONCPP_JSONCPP_LIBRARY)
 
-if (JSONCPP_FOUND)
-    if (NOT JSONCPP_FIND_QUIETLY)
-        message(STATUS "Found JSONCpp: ${JSONCPP_LIBRARIES}")
-    endif (NOT JSONCPP_FIND_QUIETLY)
-else (JSONCPP_FOUND)
-    if (JSONCPP_FIND_REQUIRED)
-        message(FATAL_ERROR "Could not find JSONCPP library, include: ${JSONCPP_INCLUDE_DIRS},
lib: ${JSONCPP_LIBRARIES}")
-    endif (JSONCPP_FIND_REQUIRED)
-endif (JSONCPP_FOUND)
+if(JSONCPP_FOUND)
+  set(JSONCPP_INCLUDE_DIRS ${JSONCPP_JSON_DIR})
+  set(JSONCPP_LIBRARIES ${JSONCPP_JSONCPP_LIBRARY})
+endif(JSONCPP_FOUND)
+unset(JSONCPP_JSON_DIR)
+unset(JSONCPP_JSONCPP_LIBRARY)
 
-mark_as_advanced(JSONCPP_LIBRARIES JSONCPP_INCLUDE_DIRS)
+mark_as_advanced(JSONCPP_INCLUDE_DIRS JSONCPP_LIBRARIES)
 
 # Restore the original find library ordering
-if (JSONCPP_USE_STATIC_LIBS)
-    set(CMAKE_FIND_LIBRARY_SUFFIXES ${_jsoncpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
-endif ()
+if(JSONCPP_USE_STATIC_LIBS)
+  set(CMAKE_FIND_LIBRARY_SUFFIXES ${_jsoncpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+endif()
diff --git a/cmake/FindLibevent.cmake b/cmake/FindLibevent.cmake
index 1b4ab65..9702f48 100755
--- a/cmake/FindLibevent.cmake
+++ b/cmake/FindLibevent.cmake
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
+#
 # - Try to find libevent
 #.rst
 # FindLibevent
@@ -37,125 +37,139 @@
 #  LIBEVENT_<C>_FOUND    - Component <C> was found (<C> is uppercase)
 #  LIBEVENT_<C>_LIBRARY  - Library to be linked for Libevent component <C>.
 
-find_package(PkgConfig QUIET)
-pkg_check_modules(PC_LIBEVENT QUIET libevent)
-
 # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
-if (Libevent_USE_STATIC_LIBS)
-    set(_libevent_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES :${CMAKE_FIND_LIBRARY_SUFFIXES})
-    if (WIN32)
-        list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a)
-    else ()
-        set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
-    endif ()
-else ()
-    set(_libevent_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES :${CMAKE_FIND_LIBRARY_SUFFIXES})
-    if (WIN32)
-        list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .dll .so)
-    elseif (APPLE)
-        set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
-    else ()
-        set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
-    endif ()
-endif ()
+if(Libevent_USE_STATIC_LIBS)
+  set(_libevent_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES
+      :${CMAKE_FIND_LIBRARY_SUFFIXES})
+  if(WIN32)
+    list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a)
+  else()
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
+  endif()
+else()
+  set(_libevent_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES
+      :${CMAKE_FIND_LIBRARY_SUFFIXES})
+  if(WIN32)
+    list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .dll .so)
+  elseif(APPLE)
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
+  else()
+    set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
+  endif()
+endif()
 
+# default search path
 set(LIBEVENT_INCLUDE_SEARCH_PATH /usr/local/include /usr/include)
 set(LIBEVENT_LIBRARIES_SEARCH_PATH /usr/local/lib /usr/lib)
-if (LIBEVENT_ROOT)
-    list(INSERT LIBEVENT_INCLUDE_SEARCH_PATH 0 ${LIBEVENT_ROOT}/include)
-    list(INSERT LIBEVENT_LIBRARIES_SEARCH_PATH 0 ${LIBEVENT_ROOT}/lib)
-endif ()
+
+# pkgconfig hint
+find_package(PkgConfig QUIET)
+pkg_check_modules(PC_LIBEVENT QUIET libevent)
+if(PC_LIBEVENT_FOUND)
+  list(INSERT LIBEVENT_INCLUDE_SEARCH_PATH 0 ${PC_LIBEVENT_INCLUDE_DIRS})
+  list(INSERT LIBEVENT_LIBRARIES_SEARCH_PATH 0 ${PC_LIBEVENT_LIBRARY_DIRS})
+endif()
+
+# custom search path
+if(LIBEVENT_ROOT)
+  list(INSERT LIBEVENT_INCLUDE_SEARCH_PATH 0 ${LIBEVENT_ROOT}/include)
+  list(INSERT LIBEVENT_LIBRARIES_SEARCH_PATH 0 ${LIBEVENT_ROOT}/lib)
+endif()
+
+set(_LIBEVENT_REQUIRED_VARS LIBEVENT_EVENT_CONFIG_DIR)
 
 # Look for the Libevent 2.0 or 1.4 headers
-find_path(LIBEVENT_INCLUDE_DIR
-        NAMES event2/event-config.h event-config.h
-        PATHS ${LIBEVENT_INCLUDE_SEARCH_PATH}
-        HINTS ${PC_LIBEVENT_INCLUDE_DIRS})
+find_path(
+  LIBEVENT_EVENT_CONFIG_DIR
+  NAMES event2/event-config.h event-config.h
+  PATHS ${LIBEVENT_INCLUDE_SEARCH_PATH}
+  NO_DEFAULT_PATH)
 
-# ------------------------------------------------------------------------
-#  Prefix initialization 
-# ------------------------------------------------------------------------
-set(Libevent_LIB_PREFIX "")
-set(LIBEVENT_EVENT_CONFIG_DIR ${LIBEVENT_INCLUDE_DIR})
-if (WIN32)
-    set(Libevent_LIB_PREFIX "lib")
-endif ()
+# Parse version
+if(LIBEVENT_EVENT_CONFIG_DIR)
+  set(_version_regex "^#define[ \t]+_EVENT_VERSION[ \t]+\"([^\"]+)\".*")
+  if(EXISTS "${LIBEVENT_EVENT_CONFIG_DIR}/event2/event-config.h")
+    # Libevent 2.0
+    file(STRINGS "${LIBEVENT_EVENT_CONFIG_DIR}/event2/event-config.h"
+         LIBEVENT_VERSION REGEX "${_version_regex}")
+    if(NOT LIBEVENT_VERSION)
+      # Libevent 2.1
+      set(_version_regex "^#define[ \t]+EVENT__VERSION[ \t]+\"([^\"]+)\".*")
+      file(STRINGS "${LIBEVENT_EVENT_CONFIG_DIR}/event2/event-config.h"
+           LIBEVENT_VERSION REGEX "${_version_regex}")
+    endif()
+  else()
+    # Libevent 1.4
+    if(EXISTS "${LIBEVENT_EVENT_CONFIG_DIR}/event-config.h")
+      file(STRINGS "${LIBEVENT_EVENT_CONFIG_DIR}/event-config.h"
+           LIBEVENT_VERSION REGEX "${_version_regex}")
+    endif()
+  endif()
+  string(REGEX REPLACE "${_version_regex}" "\\1" LIBEVENT_VERSION
+                       "${LIBEVENT_VERSION}")
+  unset(_version_regex)
+endif()
 
-if (LIBEVENT_INCLUDE_DIR)
-    set(_version_regex "^#define[ \t]+_EVENT_VERSION[ \t]+\"([^\"]+)\".*")
-    if (EXISTS "${LIBEVENT_EVENT_CONFIG_DIR}/event2/event-config.h")
-        # Libevent 2.0
-        file(STRINGS "${LIBEVENT_EVENT_CONFIG_DIR}/event2/event-config.h"
-                LIBEVENT_VERSION REGEX "${_version_regex}")
-        if (NOT LIBEVENT_VERSION)
-            # Libevent 2.1
-            set(_version_regex "^#define[ \t]+EVENT__VERSION[ \t]+\"([^\"]+)\".*")
-            file(STRINGS "${LIBEVENT_EVENT_CONFIG_DIR}/event2/event-config.h"
-                    LIBEVENT_VERSION REGEX "${_version_regex}")
-        endif ()
-    else ()
-        # Libevent 1.4
-        if (EXISTS "${LIBEVENT_EVENT_CONFIG_DIR}/event-config.h")
-            file(STRINGS "${LIBEVENT_EVENT_CONFIG_DIR}/event-config.h"
-                    LIBEVENT_VERSION REGEX "${_version_regex}")
-        endif ()
-    endif ()
-    string(REGEX REPLACE "${_version_regex}" "\\1"
-            LIBEVENT_VERSION "${LIBEVENT_VERSION}")
-    unset(_version_regex)
-endif ()
+# Prefix initialization
+if(WIN32)
+  set(Libevent_LIB_PREFIX "lib")
+else()
+  set(Libevent_LIB_PREFIX "")
+endif()
+
+if(WIN32)
+  set(Libevent_FIND_COMPONENTS ${Libevent_LIB_PREFIX}event core extra)
+else()
+  set(Libevent_FIND_COMPONENTS ${Libevent_LIB_PREFIX}event core extra pthreads)
+endif()
 
-set(_LIBEVENT_REQUIRED_VARS)
-if (WIN32)
-    set(Libevent_FIND_COMPONENTS ${Libevent_LIB_PREFIX}event core extra)
-else ()
-    set(Libevent_FIND_COMPONENTS ${Libevent_LIB_PREFIX}event core extra pthreads)
-endif ()
 message(STATUS "** libevent components: ${Libevent_FIND_COMPONENTS}")
-foreach (COMPONENT ${Libevent_FIND_COMPONENTS})
-    set(_LIBEVENT_LIBNAME "${Libevent_LIB_PREFIX}event")
-    # Note: compare two variables to avoid a CMP0054 policy warning
-    if (COMPONENT STREQUAL _LIBEVENT_LIBNAME)
-        set(_LIBEVENT_LIBNAME "${Libevent_LIB_PREFIX}event")
-    else ()
-        set(_LIBEVENT_LIBNAME "${Libevent_LIB_PREFIX}event_${COMPONENT}")
-    endif ()
-    string(TOUPPER "${COMPONENT}" COMPONENT_UPPER)
-    message(STATUS "** fine ${_LIBEVENT_LIBNAME} in ${LIBEVENT_LIBRARIES_SEARCH_PATH}")
-    find_library(LIBEVENT_${COMPONENT_UPPER}_LIBRARY
-            NAMES ${_LIBEVENT_LIBNAME}
-            PATHS ${LIBEVENT_LIBRARIES_SEARCH_PATH}
-            HINTS ${PC_LIBEVENT_LIBRARY_DIRS}
-            )
-    if (LIBEVENT_${COMPONENT_UPPER}_LIBRARY)
-        set(Libevent_${COMPONENT}_FOUND 1)
-    endif ()
-    list(APPEND _LIBEVENT_REQUIRED_VARS LIBEVENT_${COMPONENT_UPPER}_LIBRARY)
-endforeach ()
+foreach(COMPONENT ${Libevent_FIND_COMPONENTS})
+  set(_LIBEVENT_LIBNAME "${Libevent_LIB_PREFIX}event")
+  # Note: compare two variables to avoid a CMP0054 policy warning
+  if(NOT (COMPONENT STREQUAL _LIBEVENT_LIBNAME))
+    set(_LIBEVENT_LIBNAME "${Libevent_LIB_PREFIX}event_${COMPONENT}")
+  endif()
+  string(TOUPPER "${COMPONENT}" COMPONENT_UPPER)
+  message(
+    STATUS "** find ${_LIBEVENT_LIBNAME} in ${LIBEVENT_LIBRARIES_SEARCH_PATH}")
+  find_library(
+    LIBEVENT_${COMPONENT_UPPER}_LIBRARY
+    NAMES ${_LIBEVENT_LIBNAME}
+    PATHS ${LIBEVENT_LIBRARIES_SEARCH_PATH}
+    NO_DEFAULT_PATH)
+  if(LIBEVENT_${COMPONENT_UPPER}_LIBRARY)
+    set(LIBEVENT_${COMPONENT_UPPER}_FOUND ON)
+  else()
+    set(LIBEVENT_${COMPONENT_UPPER}_FOUND OFF)
+  endif()
+  list(APPEND _LIBEVENT_REQUIRED_VARS LIBEVENT_${COMPONENT_UPPER}_LIBRARY)
+endforeach()
 unset(_LIBEVENT_LIBNAME)
 
 include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set LIBEVENT_FOUND to TRUE
-# if all listed variables are TRUE and the requested version matches.
-find_package_handle_standard_args(Libevent
-        REQUIRED_VARS ${_LIBEVENT_REQUIRED_VARS} LIBEVENT_INCLUDE_DIR
-        VERSION_VAR LIBEVENT_VERSION
-        HANDLE_COMPONENTS)
+find_package_handle_standard_args(
+  Libevent
+  REQUIRED_VARS ${_LIBEVENT_REQUIRED_VARS}
+  VERSION_VAR LIBEVENT_VERSION
+  HANDLE_COMPONENTS)
+unset(_LIBEVENT_REQUIRED_VARS)
 
-if (LIBEVENT_FOUND)
-    set(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR})
-    set(LIBEVENT_LIBRARIES)
-    foreach (COMPONENT ${Libevent_FIND_COMPONENTS})
-        string(TOUPPER "${COMPONENT}" COMPONENT_UPPER)
-        list(APPEND LIBEVENT_LIBRARIES ${LIBEVENT_${COMPONENT_UPPER}_LIBRARY})
-        set(LIBEVENT_${COMPONENT_UPPER}_FOUND ${Libevent_${COMPONENT}_FOUND})
-    endforeach ()
-endif ()
+if(LIBEVENT_FOUND)
+  set(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_EVENT_CONFIG_DIR})
+  set(LIBEVENT_LIBRARIES)
+  foreach(COMPONENT ${Libevent_FIND_COMPONENTS})
+    string(TOUPPER "${COMPONENT}" COMPONENT_UPPER)
+    if(LIBEVENT_${COMPONENT_UPPER}_FOUND)
+      list(APPEND LIBEVENT_LIBRARIES ${LIBEVENT_${COMPONENT_UPPER}_LIBRARY})
+    endif()
+  endforeach()
+endif()
+unset(LIBEVENT_EVENT_CONFIG_DIR)
 
-mark_as_advanced(LIBEVENT_INCLUDE_DIR ${_LIBEVENT_REQUIRED_VARS})
+mark_as_advanced(LIBEVENT_INCLUDE_DIRS LIBEVENT_LIBRARIES)
 
 # Restore the original find library ordering
-if (Libevent_USE_STATIC_LIBS)
-    set(CMAKE_FIND_LIBRARY_SUFFIXES ${_libevent_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
-endif ()
-unset(_LIBEVENT_REQUIRED_VARS)
+if(Libevent_USE_STATIC_LIBS)
+  set(CMAKE_FIND_LIBRARY_SUFFIXES ${_libevent_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+endif()
diff --git a/project/CMakeLists.txt b/project/CMakeLists.txt
index c65d319..c79ee47 100755
--- a/project/CMakeLists.txt
+++ b/project/CMakeLists.txt
@@ -25,66 +25,71 @@ list(REMOVE_ITEM SRC_FILES ${PROJECT_SOURCE_DIR}/../src/dllmain.cpp)
 # subdirs
 set(SUB_DIRS)
 file(GLOB children ${PROJECT_SOURCE_DIR}/../src/*)
-foreach (child ${children})
-    if (IS_DIRECTORY ${child})
-        list(APPEND SUB_DIRS ${child})
-    endif ()
-endforeach ()
+foreach(child ${children})
+  if(IS_DIRECTORY ${child})
+    list(APPEND SUB_DIRS ${child})
+  endif()
+endforeach()
 list(APPEND SUB_DIRS ${PROJECT_SOURCE_DIR}/../src)
 
 # libs_directories
 file(GLOB LIB_DIRS ${PROJECT_SOURCE_DIR}/../libs/*)
-foreach (dir ${LIB_DIRS})
-    if (IS_DIRECTORY ${dir})
-        set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};${dir})
-        include_directories(${dir}/include)
-    endif ()
-endforeach ()
+foreach(dir ${LIB_DIRS})
+  if(IS_DIRECTORY ${dir})
+    set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};${dir})
+    include_directories(${dir}/include)
+  endif()
+endforeach()
 
 # static
-if (BUILD_ROCKETMQ_STATIC)
-    add_library(rocketmq_static STATIC
-            ${SRC_FILES})
-    target_include_directories(rocketmq_static
-            PUBLIC ${CMAKE_SOURCE_DIR}/include ${SUB_DIRS} ${JSONCPP_INCLUDE_DIRS} ${LIBEVENT_INCLUDE_DIRS})
-    if (spdlog_FOUND)
-        target_link_libraries(rocketmq_static
-                PUBLIC ${deplibs} Signature ${JSONCPP_LIBRARIES} ${LIBEVENT_LIBRARIES} spdlog::spdlog)
-    else (spdlog_FOUND)
-        target_link_libraries(rocketmq_static
-                PUBLIC ${deplibs} Signature ${JSONCPP_LIBRARIES} ${LIBEVENT_LIBRARIES})
-    endif (spdlog_FOUND)
-    # set_target_properties(rocketmq_static
-    #         PROPERTIES OUTPUT_NAME "rocketmq")
+if(BUILD_ROCKETMQ_STATIC)
+  add_library(rocketmq_static STATIC ${SRC_FILES})
+  target_include_directories(
+    rocketmq_static PUBLIC ${CMAKE_SOURCE_DIR}/include ${SUB_DIRS}
+                           ${JSONCPP_INCLUDE_DIRS} ${LIBEVENT_INCLUDE_DIRS})
+  if(spdlog_FOUND)
+    target_link_libraries(
+      rocketmq_static PUBLIC ${deplibs} Signature ${JSONCPP_LIBRARIES}
+                             ${LIBEVENT_LIBRARIES} spdlog::spdlog)
+  else(spdlog_FOUND)
+    target_link_libraries(
+      rocketmq_static PUBLIC ${deplibs} Signature ${JSONCPP_LIBRARIES}
+                             ${LIBEVENT_LIBRARIES})
+  endif(spdlog_FOUND)
+  # set_target_properties(rocketmq_static PROPERTIES OUTPUT_NAME "rocketmq")
 
-    include(BundleStaticLibrary)
-    bundle_static_library(rocketmq_static rocketmq)
-endif ()
+  include(BundleStaticLibrary)
+  bundle_static_library(rocketmq_static rocketmq)
+endif()
 
 # shared
-if (BUILD_ROCKETMQ_SHARED)
-    add_library(rocketmq_shared SHARED
-            ${SRC_FILES})
-    target_include_directories(rocketmq_shared
-            PUBLIC ${CMAKE_SOURCE_DIR}/include ${SUB_DIRS} ${JSONCPP_INCLUDE_DIRS} ${LIBEVENT_INCLUDE_DIRS})
-    if (spdlog_FOUND)
-        target_link_libraries(rocketmq_shared
-                PUBLIC ${deplibs} Signature ${JSONCPP_LIBRARIES} ${LIBEVENT_LIBRARIES} spdlog::spdlog)
-    else (spdlog_FOUND)
-        target_link_libraries(rocketmq_shared
-                PUBLIC ${deplibs} Signature ${JSONCPP_LIBRARIES} ${LIBEVENT_LIBRARIES})
-    endif (spdlog_FOUND)
-    set_target_properties(rocketmq_shared
-            PROPERTIES OUTPUT_NAME "rocketmq")
-endif ()
+if(BUILD_ROCKETMQ_SHARED)
+  add_library(rocketmq_shared SHARED ${SRC_FILES})
+  target_include_directories(
+    rocketmq_shared PUBLIC ${CMAKE_SOURCE_DIR}/include ${SUB_DIRS}
+                           ${JSONCPP_INCLUDE_DIRS} ${LIBEVENT_INCLUDE_DIRS})
+  if(spdlog_FOUND)
+    target_link_libraries(
+      rocketmq_shared PUBLIC ${deplibs} Signature ${JSONCPP_LIBRARIES}
+                             ${LIBEVENT_LIBRARIES} spdlog::spdlog)
+  else(spdlog_FOUND)
+    target_link_libraries(
+      rocketmq_shared PUBLIC ${deplibs} Signature ${JSONCPP_LIBRARIES}
+                             ${LIBEVENT_LIBRARIES})
+  endif(spdlog_FOUND)
+  set_target_properties(rocketmq_shared PROPERTIES OUTPUT_NAME "rocketmq")
+endif()
 
 # install
-if (BUILD_ROCKETMQ_STATIC)
-    install(TARGETS rocketmq_static DESTINATION lib)
-    install(FILES ${LIBRARY_OUTPUT_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}rocketmq${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION lib)
-endif ()
-if (BUILD_ROCKETMQ_SHARED)
-    install(TARGETS rocketmq_shared DESTINATION lib)
-endif ()
+if(BUILD_ROCKETMQ_STATIC)
+  install(TARGETS rocketmq_static DESTINATION lib)
+  install(
+    FILES
+      ${LIBRARY_OUTPUT_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}rocketmq${CMAKE_STATIC_LIBRARY_SUFFIX}
+    DESTINATION lib)
+endif()
+if(BUILD_ROCKETMQ_SHARED)
+  install(TARGETS rocketmq_shared DESTINATION lib)
+endif()
 install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/rocketmq)
 install(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/ DESTINATION doc)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d6e56eb..203a268 100755
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -19,73 +19,77 @@ set(CMAKE_BUILD_TYPE "Debug")
 
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
 
-set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${CMAKE_SOURCE_DIR}/bin/lib64/cmake;${CMAKE_SOURCE_DIR}/bin/lib/cmake")
+set(CMAKE_PREFIX_PATH
+    "${CMAKE_PREFIX_PATH};${CMAKE_SOURCE_DIR}/bin/lib64/cmake;${CMAKE_SOURCE_DIR}/bin/lib/cmake"
+)
 
-# Find dependencies
-#find_package(GTest REQUIRED CONFIG)
-if (NOT GTest_FOUND)
-    include_directories("${CMAKE_SOURCE_DIR}/bin/include")
+# Find dependencies find_package(GTest REQUIRED CONFIG)
+if(NOT GTest_FOUND)
+  include_directories("${CMAKE_SOURCE_DIR}/bin/include")
 
-    if (EXISTS "${CMAKE_SOURCE_DIR}/bin/lib64/libgtest.a")
-        set(Gtest_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/bin/lib64")
-    else ()
-        set(Gtest_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/bin/lib")
-    endif ()
-    link_libraries("${Gtest_LIBRARY_DIR}/libgtest.a" "${Gtest_LIBRARY_DIR}/libgtest_main.a"
-        "${Gtest_LIBRARY_DIR}/libgmock.a" "${Gtest_LIBRARY_DIR}/libgmock_main.a")
-endif ()
+  if(EXISTS "${CMAKE_SOURCE_DIR}/bin/lib64/libgtest.a")
+    set(Gtest_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/bin/lib64")
+  else()
+    set(Gtest_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/bin/lib")
+  endif()
+  link_libraries(
+    "${Gtest_LIBRARY_DIR}/libgtest.a" "${Gtest_LIBRARY_DIR}/libgtest_main.a"
+    "${Gtest_LIBRARY_DIR}/libgmock.a" "${Gtest_LIBRARY_DIR}/libgmock_main.a")
+endif()
 
-if (NOT (CMAKE_VERSION VERSION_LESS "3.9"))
-    cmake_policy(SET CMP0054 NEW)
-    cmake_policy(SET CMP0057 NEW)
-    include(GoogleTest)
-endif ()
+if(NOT (CMAKE_VERSION VERSION_LESS "3.9"))
+  cmake_policy(SET CMP0054 NEW)
+  cmake_policy(SET CMP0057 NEW)
+  include(GoogleTest)
+endif()
 
 function(config_test file)
-    get_filename_component(basename ${file} NAME_WE)
+  get_filename_component(basename ${file} NAME_WE)
 
-    add_executable(${basename} ${file})
+  add_executable(${basename} ${file})
 
-    if(MSVC)
-        if(CMAKE_CONFIGURATION_TYPES STREQUAL "Release")
-            set_target_properties(${basename} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT")
-        else()
-            set_target_properties(${basename} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMTD")
-        endif()
+  if(MSVC)
+    if(CMAKE_CONFIGURATION_TYPES STREQUAL "Release")
+      set_target_properties(${basename} PROPERTIES LINK_FLAGS
+                                                   "/NODEFAULTLIB:LIBCMT")
+    else()
+      set_target_properties(${basename} PROPERTIES LINK_FLAGS
+                                                   "/NODEFAULTLIB:LIBCMTD")
     endif()
+  endif()
 
-    if (GTest_FOUND)
-        if (BUILD_ROCKETMQ_SHARED)
-            target_link_libraries(${basename} rocketmq_shared
-                GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
-        else (BUILD_ROCKETMQ_SHARED)
-            target_link_libraries(${basename} rocketmq_static
-                GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
-        endif (BUILD_ROCKETMQ_SHARED)
-    else ()
-        if (BUILD_ROCKETMQ_SHARED)
-            target_link_libraries(${basename} rocketmq_shared)
-        else (BUILD_ROCKETMQ_SHARED)
-            target_link_libraries(${basename} rocketmq_static)
-        endif (BUILD_ROCKETMQ_SHARED)
-    endif ()
+  if(GTest_FOUND)
+    if(BUILD_ROCKETMQ_SHARED)
+      target_link_libraries(${basename} rocketmq_shared GTest::gtest
+                            GTest::gtest_main GTest::gmock GTest::gmock_main)
+    else(BUILD_ROCKETMQ_SHARED)
+      target_link_libraries(${basename} rocketmq_static GTest::gtest
+                            GTest::gtest_main GTest::gmock GTest::gmock_main)
+    endif(BUILD_ROCKETMQ_SHARED)
+  else()
+    if(BUILD_ROCKETMQ_SHARED)
+      target_link_libraries(${basename} rocketmq_shared)
+    else(BUILD_ROCKETMQ_SHARED)
+      target_link_libraries(${basename} rocketmq_static)
+    endif(BUILD_ROCKETMQ_SHARED)
+  endif()
 
-    if (NOT (CMAKE_VERSION VERSION_LESS "3.10"))
-        gtest_discover_tests(${basename})
-    elseif (NOT (CMAKE_VERSION VERSION_LESS "3.9"))
-        gtest_add_tests(TARGET ${basename})
-    endif ()
+  if(NOT (CMAKE_VERSION VERSION_LESS "3.10"))
+    gtest_discover_tests(${basename})
+  elseif(NOT (CMAKE_VERSION VERSION_LESS "3.9"))
+    gtest_add_tests(TARGET ${basename})
+  endif()
 endfunction()
 
 function(config_all_test dir)
-    file(GLOB files "${dir}/*")
-    foreach (file ${files})
-        if (IS_DIRECTORY ${file})
-            config_all_test(${file})
-        elseif (${file} MATCHES "^.+\\.(c|cpp)$")
-            config_test(${file})
-        endif ()
-    endforeach ()
+  file(GLOB files "${dir}/*")
+  foreach(file ${files})
+    if(IS_DIRECTORY ${file})
+      config_all_test(${file})
+    elseif(${file} MATCHES "^.+\\.(c|cpp)$")
+      config_test(${file})
+    endif()
+  endforeach()
 endfunction()
 
 config_all_test(${PROJECT_SOURCE_DIR}/src)

Mime
View raw message