forked from yesup/tensorflow-serving-client-java
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
62 lines (53 loc) · 2.61 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
cmake_minimum_required(VERSION 3.8)
set(TFSCLIENT_NAME "$ENV{TFSCLIENT_NAME}")
set(TFSCLIENT_VERSION "$ENV{TFSCLIENT_VERSION}")
set(TFSCLIENT_VERSION_GRPC "$ENV{TFSCLIENT_VERSION_GRPC}")
set(TFSCLIENT_VERSION_PROTO "$ENV{TFSCLIENT_VERSION_PROTO}")
project(${TFSCLIENT_NAME} VERSION ${TFSCLIENT_VERSION})
find_package(Protobuf ${TFSCLIENT_VERSION_PROTO} REQUIRED)
find_package(gRPC ${TFSCLIENT_VERSOIN_GRPC} CONFIG)
if(gRPC_FOUND)
set(GRPCPP_INCLUDE_DIRS $<TARGET_PROPERTY:gRPC::grpc++,INTERFACE_INCLUDE_DIRECTORIES>)
set(GRPCPP_LIBRARIES $<TARGET_PROPERTY:gRPC::grpc++,INTERFACE_LINK_LIBRARIES>)
else()
find_package(PkgConfig REQUIRED)
pkg_search_module(GRPC REQUIRED grpc)
pkg_search_module(GRPCPP REQUIRED grpc++>=${TFSCLIENT_VERSION_GRPC})
list(APPEND GRPCPP_INCLUDE_DIRS ${GRPC_INCLUDE_DIRS})
list(APPEND GRPCPP_LIBRARIES ${GRPC_LIBRARIES})
endif()
set(PROTO_GENERATED "${CMAKE_SOURCE_DIR}/$ENV{TFSCLIENT_SOURCE}")
file(GLOB_RECURSE PROTO_SOURCES "${PROTO_GENERATED}/*.cc")
add_library(${TFSCLIENT_NAME} STATIC ${PROTO_SOURCES})
target_compile_features(${TFSCLIENT_NAME} PUBLIC cxx_std_11)
target_include_directories(${TFSCLIENT_NAME}
PUBLIC
$<BUILD_INTERFACE:${PROTO_GENERATED}>
$<INSTALL_INTERFACE:include>
PRIVATE
${GRPCPP_INCLUDE_DIRS}
${PROTOBUF_INCLUDE_DIRS})
target_link_libraries(${TFSCLIENT_NAME}
PUBLIC
${GRPCPP_LIBRARIES}
${PROTOBUF_LIBRARIES})
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_VERSION ${TFSCLIENT_VERSION})
set(CPACK_PACKAGE_VENDOR "$ENV{TFSCLIENT_AUTHOR_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "$ENV{TFSCLIENT_DESCRIPTION}")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
include(CPack)
set(TFSCLIENT_TARGETS "${TFSCLIENT_NAME}-targets")
set(TFSCLIENT_TARGETF "${TFSCLIENT_TARGETS}.cmake")
set(TFSCLIENT_CONFIGF "${TFSCLIENT_NAME}-config.cmake")
install(TARGETS ${TFSCLIENT_NAME} EXPORT ${TFSCLIENT_TARGETS}
ARCHIVE DESTINATION lib INCLUDES DESTINATION include)
install(EXPORT ${TFSCLIENT_TARGETS} FILE ${TFSCLIENT_TARGETF} DESTINATION lib/cmake)
install(DIRECTORY "${PROTO_GENERATED}/" DESTINATION include FILES_MATCHING PATTERN "*.h")
include(CMakePackageConfigHelpers)
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${TFSCLIENT_CONFIGF}" INSTALL_DESTINATION lib/cmake
NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${TFSCLIENT_CONFIGF}" DESTINATION lib/cmake)
export(EXPORT ${TFSCLIENT_TARGETS} FILE "${CMAKE_CURRENT_BINARY_DIR}/${TFSCLIENT_TARGETF}")