diff --git a/CMakeLists.txt b/CMakeLists.txt index a851c00..d18ecd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ if(BRPC_WITH_GLOG) ${OPENSSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} dl - z + ZLIB::ZLIB ) else() set(DYNAMIC_LIB @@ -117,7 +117,7 @@ else() ${OPENSSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} dl - z + ZLIB::ZLIB ) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 78adc56..0ab4dce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,8 +19,10 @@ add_library(braft-static STATIC $) endif() if (BUILD_SHARED_LIBS) +target_include_directories(braft-shared PUBLIC $) target_link_libraries(braft-shared PUBLIC ${DYNAMIC_LIB}) else() +target_include_directories(braft-static PUBLIC $) target_link_libraries(braft-static PUBLIC ${DYNAMIC_LIB}) endif() @@ -31,15 +33,31 @@ SET_TARGET_PROPERTIES(braft-shared PROPERTIES OUTPUT_NAME braft CLEAN_DIRECT_OUT endif() if (NOT BUILD_SHARED_LIBS) -install(TARGETS braft-static +install(TARGETS braft-static EXPORT unofficial-braftTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIBSUFFIX} ARCHIVE DESTINATION lib${LIBSUFFIX} ) else() -install(TARGETS braft-shared +install(TARGETS braft-shared EXPORT unofficial-braftTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIBSUFFIX} ARCHIVE DESTINATION lib${LIBSUFFIX} ) endif() + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-braft-config.cmake" +[[include(CMakeFindDependencyMacro) +find_dependency(ZLIB) +find_dependency(gflags CONFIG) +file(GLOB TARGET_FILES "${CMAKE_CURRENT_LIST_DIR}/unofficial-braftTargets.cmake") +foreach (TARGET_FILE ${TARGET_FILES}) + include("${TARGET_FILE}") +endforeach() +]]) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-braft-config.cmake" DESTINATION share/unofficial-braft) + +install(EXPORT unofficial-braftTargets + NAMESPACE unofficial::braft:: + DESTINATION share/unofficial-braft +)