Skip to content

Commit de88d6f

Browse files
CMakeLists.txt: allow compilation without CXX support #4364
e.g. fluent-bit is a c-only library, so allow compilation without cxx Signed-off-by: Thomas Devoogdt <[email protected]>
1 parent c07a335 commit de88d6f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ cmake_minimum_required(VERSION 3.2)
33
include("packaging/cmake/parseversion.cmake")
44
parseversion("src/rdkafka.h")
55

6-
project(RdKafka VERSION ${RDKAFKA_VERSION})
6+
option(RDKAFKA_BUILD_CXX "Enable CXX support" ON)
7+
set(RDKAFKA_LANGUAGES C)
8+
if(RDKAFKA_BUILD_CXX)
9+
set(RDKAFKA_LANGUAGES ${RDKAFKA_LANGUAGES} CXX)
10+
endif()
11+
12+
project(RdKafka VERSION ${RDKAFKA_VERSION} LANGUAGES ${RDKAFKA_LANGUAGES})
713

814
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/packaging/cmake/Modules/")
915

@@ -180,8 +186,8 @@ endif()
180186
# }
181187

182188
option(RDKAFKA_BUILD_STATIC "Build static rdkafka library" OFF)
183-
option(RDKAFKA_BUILD_EXAMPLES "Build examples" ON)
184-
option(RDKAFKA_BUILD_TESTS "Build tests" ON)
189+
option(RDKAFKA_BUILD_EXAMPLES "Build examples" RDKAFKA_BUILD_CXX)
190+
option(RDKAFKA_BUILD_TESTS "Build tests" RDKAFKA_BUILD_CXX)
185191
if(WIN32)
186192
option(WITHOUT_WIN32_CONFIG "Avoid including win32_config.h on cmake builds" ON)
187193
endif(WIN32)
@@ -279,7 +285,9 @@ install(
279285
)
280286

281287
add_subdirectory(src)
282-
add_subdirectory(src-cpp)
288+
if(RDKAFKA_BUILD_CXX)
289+
add_subdirectory(src-cpp)
290+
endif()
283291

284292
if(RDKAFKA_BUILD_EXAMPLES)
285293
add_subdirectory(examples)

0 commit comments

Comments
 (0)