forked from NuclearAPK/Simple-Kafka_Adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
105 lines (88 loc) · 3.1 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
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.12)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_LEGACY_CYGWIN_WIN32 0)
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.0)
# Enable MACOSX_RPATH by default
cmake_policy (SET CMP0042 NEW)
endif()
if (NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
endif()
project (SimpleKafka1C)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR})
find_package(Boost 1.38 REQUIRED COMPONENTS filesystem iostreams program_options regex system json)
find_package(Snappy)
if (SNAPPY_FOUND)
set(SNAPPY_PKG libsnappy)
add_definitions(-DSNAPPY_CODEC_AVAILABLE)
message("Enabled snappy codec")
else (SNAPPY_FOUND)
set(SNAPPY_PKG "")
set(SNAPPY_LIBRARIES "")
set(SNAPPY_INCLUDE_DIR "")
message("Disabled snappy codec. libsnappy not found.")
endif (SNAPPY_FOUND)
find_package(RdKafka CONFIG REQUIRED)
add_definitions (${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
add_definitions("-DLIBRDKAFKA_STATICLIB")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -flto -s -O3 -DNDEBUG")
endif ()
set(SOURCE_FILES
src/stdafx.h
src/exports.cpp
src/md5.cpp
src/md5.h
src/Component.cpp
src/Component.h
src/SimpleKafka1C.cpp
src/SimpleKafka1C.h)
add_library(SimpleKafka1C SHARED ${SOURCE_FILES})
if (WIN32)
find_package(unofficial-avro-cpp CONFIG REQUIRED)
target_include_directories(SimpleKafka1C PRIVATE include ${SOURCES}/include
${Boost_INCLUDE_DIRS}
${RdKafka_INCLUDE_DIRS}
${unofficial-avro-cpp_INCLUDE_DIRS})
target_link_libraries(SimpleKafka1C ${Boost_LIBRARIES}
${SNAPPY_LIBRARIES}
RdKafka::rdkafka RdKafka::rdkafka++
unofficial::avro-cpp::avrocpp)
else()
target_include_directories(SimpleKafka1C PRIVATE include ${SOURCES}/include
${Boost_INCLUDE_DIRS}
${RdKafka_INCLUDE_DIRS}
/home/source/avro-src-1.11.3/lang/c++/api)
target_link_libraries(SimpleKafka1C ${Boost_LIBRARIES}
${SNAPPY_LIBRARIES}
/home/source/avro-src-1.11.3/lang/c++/libavrocpp_s.a
/home/source/vcpkg/installed/x64-linux/lib/libboost_iostreams.a
/home/source/vcpkg/installed/x64-linux/lib/libsnappy.a
/home/source/vcpkg/installed/x64-linux/lib/libz.a
RdKafka::rdkafka RdKafka::rdkafka++)
endif ()
if (WIN32 AND NOT MSVC)
message(FATAL_ERROR "Must be compiled with MSVC on Windows")
endif ()
if (WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
target_compile_definitions(SimpleKafka1C PRIVATE
_WINDOWS
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
target_compile_options(SimpleKafka1C PRIVATE /utf-8)
else ()
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
message("CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
endif (NOT CMAKE_BUILD_TYPE)
endif ()