Skip to content

Commit 73aa4e5

Browse files
committed
Now it works without boost if you don't want the examples.
1 parent e5358fa commit 73aa4e5

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

CMakeLists.txt

+22-22
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,6 @@ if (NOT CPPKAFKA_PKGCONFIG_DIR)
104104
set(CPPKAFKA_PKGCONFIG_DIR share/pkgconfig)
105105
endif()
106106

107-
# Look for Boost (just need boost.optional headers here)
108-
find_package(Boost REQUIRED ${FIND_PACKAGE_QUIET})
109-
110-
if (Boost_FOUND)
111-
find_package(Boost COMPONENTS program_options ${FIND_PACKAGE_QUIET})
112-
set(Boost_USE_STATIC_LIBS ${CPPKAFKA_BOOST_STATIC_LIBS})
113-
set(Boost_USE_MULTITHREADED ${CPPKAFKA_BOOST_USE_MULTITHREADED})
114-
include_directories(${Boost_INCLUDE_DIRS})
115-
link_directories(${Boost_LIBRARY_DIRS})
116-
if (CPPKAFKA_CMAKE_VERBOSE)
117-
message(STATUS "Boost include dir: ${Boost_INCLUDE_DIRS}")
118-
message(STATUS "Boost library dir: ${Boost_LIBRARY_DIRS}")
119-
message(STATUS "Boost use static libs: ${Boost_USE_STATIC_LIBS}")
120-
message(STATUS "Boost is multi-threaded: ${CPPKAFKA_BOOST_USE_MULTITHREADED}")
121-
message(STATUS "Boost libraries: ${Boost_LIBRARIES}")
122-
endif()
123-
endif()
124-
125107
# Try to find the RdKafka configuration file if present.
126108
# This will search default system locations as well as RdKafka_ROOT and RdKafka_Dir paths if specified.
127109
find_package(RdKafka ${FIND_PACKAGE_QUIET} CONFIG)
@@ -142,10 +124,28 @@ add_subdirectory(src)
142124
add_subdirectory(include/cppkafka)
143125

144126
# Examples target
145-
if (NOT CPPKAFKA_DISABLE_EXAMPLES AND Boost_PROGRAM_OPTIONS_FOUND)
146-
add_subdirectory(examples)
147-
else()
148-
message(STATUS "Disabling examples")
127+
if (NOT CPPKAFKA_DISABLE_EXAMPLES)
128+
# Look for Boost (just need boost.optional headers here)
129+
find_package(Boost ${FIND_PACKAGE_QUIET} CONFIG)
130+
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+
find_package(Boost COMPONENTS program_options ${FIND_PACKAGE_QUIET})
134+
set(Boost_USE_STATIC_LIBS ${CPPKAFKA_BOOST_STATIC_LIBS})
135+
set(Boost_USE_MULTITHREADED ${CPPKAFKA_BOOST_USE_MULTITHREADED})
136+
include_directories(${Boost_INCLUDE_DIRS})
137+
link_directories(${Boost_LIBRARY_DIRS})
138+
if (CPPKAFKA_CMAKE_VERBOSE)
139+
message(STATUS "Boost include dir: ${Boost_INCLUDE_DIRS}")
140+
message(STATUS "Boost library dir: ${Boost_LIBRARY_DIRS}")
141+
message(STATUS "Boost use static libs: ${Boost_USE_STATIC_LIBS}")
142+
message(STATUS "Boost is multi-threaded: ${CPPKAFKA_BOOST_USE_MULTITHREADED}")
143+
message(STATUS "Boost libraries: ${Boost_LIBRARIES}")
144+
endif()
145+
add_subdirectory(examples)
146+
else()
147+
message(STATUS "Disabling examples")
148+
endif()
149149
endif()
150150

151151
# Add a target to generate API documentation using Doxygen

src/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ set_target_properties(${TARGET_NAME} PROPERTIES
4747
VERSION ${CPPKAFKA_VERSION}
4848
SOVERSION ${CPPKAFKA_VERSION})
4949
# In CMake >= 3.15 Boost::boost == Boost::headers
50-
target_link_libraries(${TARGET_NAME} PUBLIC RdKafka::rdkafka Boost::boost)
50+
target_link_libraries(${TARGET_NAME} PUBLIC RdKafka::rdkafka)
51+
52+
if(NOT CPPKAFKA_DISABLE_EXAMPLES)
53+
target_link_libraries(${TARGET_NAME} PUBLIC Boost::boost)
54+
endif()
55+
5156
if (WIN32)
5257
# On windows ntohs and related are in ws2_32
5358
target_link_libraries(${TARGET_NAME} PUBLIC ws2_32.lib)

0 commit comments

Comments
 (0)