@@ -16,6 +16,8 @@ set(CPPKAFKA_VERSION "${CPPKAFKA_VERSION_MAJOR}.${CPPKAFKA_VERSION_MINOR}.${CPPK
16
16
set (RDKAFKA_MIN_VERSION "0.9.4" )
17
17
set (RDKAFKA_MIN_VERSION_HEX 0x00090400)
18
18
19
+ option (USE_CPP17 "Use C++17 features instead of Boost (still, if you don't have boost you can't build examples" OFF )
20
+
19
21
if (NOT CMAKE_CXX_FLAGS )
20
22
# Set default compile flags for the project
21
23
if (MSVC )
@@ -31,8 +33,13 @@ if (NOT CMAKE_CXX_FLAGS)
31
33
set (CMAKE_CXX_FLAGS "-Wall" )
32
34
endif ()
33
35
endif ()
34
- # Use C++17
35
- set (CMAKE_CXX_STANDARD 17)
36
+
37
+ if (USE_CPP17)
38
+ set (CMAKE_CXX_STANDARD 17)
39
+ add_definitions ("-D_USE_CPP17" )
40
+ else ()
41
+ set (CMAKE_CXX_STANDARD 11)
42
+ endif ()
36
43
37
44
# Set output directories
38
45
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /lib)
@@ -104,32 +111,11 @@ if (NOT CPPKAFKA_PKGCONFIG_DIR)
104
111
set (CPPKAFKA_PKGCONFIG_DIR share/pkgconfig)
105
112
endif ()
106
113
107
- # Try to find the RdKafka configuration file if present.
108
- # This will search default system locations as well as RdKafka_ROOT and RdKafka_Dir paths if specified.
109
- find_package (RdKafka ${FIND_PACKAGE_QUIET} CONFIG)
110
- set (RDKAFKA_TARGET_IMPORTS ${RdKafka_FOUND} )
111
- if (NOT RdKafka_FOUND)
112
- message (STATUS "RdKafkaConfig.cmake not found. Attempting to find module instead..." )
113
- find_package (RdKafka REQUIRED ${FIND_PACKAGE_QUIET} MODULE)
114
- if (NOT RdKafka_FOUND)
115
- message (FATAL_ERROR "RdKafka module not found. Please set RDKAFKA_ROOT to the install path or RDKAFKA_DIR pointing to the RdKafka configuration file location." )
116
- else ()
117
- message (STATUS "RdKafka module found." )
118
- endif ()
119
- else ()
120
- message (STATUS "RdKafka configuration file found: ${RdKafka_CONFIG} " )
121
- endif ()
122
-
123
- add_subdirectory (src)
124
- add_subdirectory (include /cppkafka)
125
-
126
- # Examples target
127
- if (NOT CPPKAFKA_DISABLE_EXAMPLES)
114
+ if (NOT USE_CPP17 OR NOT CPPKAFKA_DISABLE_EXAMPLES OR NOT CPPKAFKA_DISABLE_TESTS)
128
115
# Look for Boost (just need boost.optional headers here)
129
- find_package (Boost ${FIND_PACKAGE_QUIET} CONFIG)
116
+ find_package (Boost REQUIRED ${FIND_PACKAGE_QUIET} )
117
+
130
118
if (Boost_FOUND)
131
- option (CPPKAFKA_BOOST_STATIC_LIBS "Link with Boost static libraries." ON )
132
- option (CPPKAFKA_BOOST_USE_MULTITHREADED "Use Boost multithreaded libraries." ON )
133
119
find_package (Boost COMPONENTS program_options ${FIND_PACKAGE_QUIET} )
134
120
set (Boost_USE_STATIC_LIBS ${CPPKAFKA_BOOST_STATIC_LIBS} )
135
121
set (Boost_USE_MULTITHREADED ${CPPKAFKA_BOOST_USE_MULTITHREADED} )
@@ -142,12 +128,37 @@ if (NOT CPPKAFKA_DISABLE_EXAMPLES)
142
128
message (STATUS "Boost is multi-threaded: ${CPPKAFKA_BOOST_USE_MULTITHREADED} " )
143
129
message (STATUS "Boost libraries: ${Boost_LIBRARIES} " )
144
130
endif ()
131
+ endif ()
132
+
133
+ # Examples target
134
+ if (Boost_PROGRAM_OPTIONS_FOUND)
145
135
add_subdirectory (examples)
146
136
else ()
147
137
message (STATUS "Disabling examples" )
148
138
endif ()
149
139
endif ()
150
140
141
+ # Try to find the RdKafka configuration file if present.
142
+ # This will search default system locations as well as RdKafka_ROOT and RdKafka_Dir paths if specified.
143
+ find_package (RdKafka ${FIND_PACKAGE_QUIET} CONFIG)
144
+ set (RDKAFKA_TARGET_IMPORTS ${RdKafka_FOUND} )
145
+ if (NOT RdKafka_FOUND)
146
+ message (STATUS "RdKafkaConfig.cmake not found. Attempting to find module instead..." )
147
+ find_package (RdKafka REQUIRED ${FIND_PACKAGE_QUIET} MODULE)
148
+ if (NOT RdKafka_FOUND)
149
+ message (FATAL_ERROR "RdKafka module not found. Please set RDKAFKA_ROOT to the install path or RDKAFKA_DIR pointing to the RdKafka configuration file location." )
150
+ else ()
151
+ message (STATUS "RdKafka module found." )
152
+ endif ()
153
+ else ()
154
+ message (STATUS "RdKafka configuration file found: ${RdKafka_CONFIG} " )
155
+ endif ()
156
+
157
+ add_subdirectory (src)
158
+ add_subdirectory (include /cppkafka)
159
+
160
+
161
+
151
162
# Add a target to generate API documentation using Doxygen
152
163
find_package (Doxygen ${FIND_PACKAGE_QUIET} )
153
164
if (DOXYGEN_FOUND)
@@ -188,4 +199,4 @@ if(NOT TARGET uninstall)
188
199
# Add uninstall target
189
200
add_custom_target (uninstall
190
201
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR} /cmake_uninstall.cmake)
191
- endif ()
202
+ endif ()
0 commit comments