-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
125 lines (107 loc) · 3.55 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
project(tflogger C CXX)
cmake_minimum_required(VERSION 3.12)
include(CMakePackageConfigHelpers)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(TFLOGGER_VERSION_MAJOR 1)
set(TFLOGGER_VERSION_MINOR 0)
set(TFLOGGER_VERSION_PATCH 1)
set(TFLOGGER_VERSION "${TFLOGGER_VERSION_MAJOR}.${TFLOGGER_VERSION_MINOR}.${TFLOGGER_VERSION_PATCH}")
set(TFLOGGER_SOVERSION_MAJOR 1)
set(TFLOGGER_SOVERSION_MINOR 0)
set(TFLOGGER_SOVERSION_PATCH 0)
set(TFLOGGER_SOVERSION "${TFLOGGER_SOVERSION_MAJOR}.${TFLOGGER_SOVERSION_MINOR}.${TFLOGGER_SOVERSION_PATCH}")
if(NOT LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR lib)
endif()
if(NOT INCLUDE_INSTALL_DIR)
set(INCLUDE_INSTALL_DIR include)
endif()
find_package(Protobuf REQUIRED)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tflogger/proto)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS
tflogger/pb/event.proto
tflogger/pb/summary.proto
PROTOC_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/tflogger/proto)
set(TFLOGGER_SRC
tflogger/crc32/crc32c.cc
tflogger/crc32/crc32c_accelerate.cc
tflogger/record/record_reader.cc
tflogger/record/record_writer.cc
tflogger/event_logger.cc
tflogger/event_reader.cc
tflogger/utils.cc
${PROTO_SRCS})
set(TFLOGGER_HEADERS
tflogger/record/record_reader.h
tflogger/record/record_writer.h
tflogger/event_logger.h
tflogger/event_reader.h
tflogger/utils.h)
add_library(tflogger ${TFLOGGER_SRC})
target_link_libraries(tflogger PUBLIC protobuf::libprotobuf)
set_target_properties(tflogger
PROPERTIES
SOVERSION ${TFLOGGER_SOVERSION}
VERSION ${TFLOGGER_VERSION}
)
add_library(tflogger::tflogger ALIAS tflogger)
OPTION(BUILD_EXAMPLES "Build examples")
if(BUILD_EXAMPLES)
add_subdirectory(examples/cpp)
endif()
OPTION(BUILD_TESTS "Build tests")
if(BUILD_TESTS)
find_package(Catch2 CONFIG)
set(THIRD_PARTY_PATH ${CMAKE_SOURCE_DIR}/third_party)
enable_testing()
add_subdirectory(test)
endif()
OPTION(INTERFACE_PYTHON "Create Python wrapper")
if(INTERFACE_PYTHON)
find_package(SWIG REQUIRED)
add_subdirectory(python)
endif()
INSTALL(FILES ${TFLOGGER_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/tflogger)
INSTALL(
FILES tflogger/record/record_reader.h tflogger/record/record_writer.h
DESTINATION ${INCLUDE_INSTALL_DIR}/tflogger/record)
INSTALL(FILES tflogger/crc32/crc32c.h DESTINATION ${INCLUDE_INSTALL_DIR}/tflogger/crc32)
INSTALL(FILES ${PROTO_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/tflogger/proto)
INSTALL(
TARGETS tflogger
EXPORT TFLoggerTargets
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR}
)
set(CONFIG_PACKAGE_DIR ${LIB_INSTALL_DIR}/cmake/tflogger)
configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/TFLoggerConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/TFLoggerConfig.cmake
INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/tflogger
PATH_VARS INCLUDE_INSTALL_DIR CONFIG_PACKAGE_DIR)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/TFLoggerConfigVersion.cmake"
VERSION ${TFLOGGER_VERSION}
COMPATIBILITY SameMajorVersion
)
export(EXPORT TFLoggerTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/TFLoggerTargets.cmake"
NAMESPACE tflogger::
)
install(
EXPORT TFLoggerTargets
FILE TFLoggerTargets.cmake
NAMESPACE tflogger::
DESTINATION ${CONFIG_PACKAGE_DIR}
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/TFLoggerConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/TFLoggerConfigVersion.cmake"
DESTINATION ${CONFIG_PACKAGE_DIR}
)