Skip to content

Conversation

@beryll1um
Copy link
Contributor

Causes build to fail, with a typical error message about the missing header.

cmake_minimum_required(VERSION 3.14)
project(XXX LANGUAGES CXX)

set(USERVER_PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/submodules/userver")
if(EXISTS ${USERVER_PROJECT_DIR})
	add_subdirectory(${USERVER_PROJECT_DIR})
else()
	message(FATAL_ERROR "Unable to locate userver in the submodules directory")
endif()

file(GLOB_RECURSE XXX_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
add_executable(${PROJECT_NAME} ${XXX_SRC_FILES})
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)

userver_setup_environment()
target_link_libraries(${PROJECT_NAME} PUBLIC userver::core userver::kafka)
// src/main.cpp

#include <userver/components/minimal_server_component_list.hpp>
#include <userver/utils/daemon_run.hpp>

int main(int argc, char* argv[])
{
	auto components_list = userver::components::MinimalServerComponentList();
	return userver::utils::DaemonMain(argc, argv, components_list);
}
cmake -B build -DUSERVER_FEATURE_UTEST=OFF -DUSERVER_FEATURE_STACKTRACE=OFF -DUSERVER_FEATURE_KAFKA=ON
cmake --build build -- -j 16
submodules/userver/kafka/src/kafka/impl/holders.cpp:7:10: fatal error: librdkafka/rdkafka_mock.h: No such file or directory
    7 | #include <librdkafka/rdkafka_mock.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

63de2c9 adds the include directive for this header, but the wrapper header rdkafka_mock.h itself was not provided.

Causes build to fail, with a typical error message about the missing header.
@beryll1um
Copy link
Contributor Author

From what I understand, it was unknown for so long because it only affects the CPM Kafka setup.

# userver/kafka/CMakeLists.txt

project(userver-kafka CXX)

if(USERVER_CONAN)
    find_package(RdKafka REQUIRED)
else()
    include(SetupRdKafka)
endif()

userver_module(
    kafka
    SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
    LINK_LIBRARIES_PRIVATE RdKafka::rdkafka
    DBTEST_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests"
    DBTEST_LINK_LIBRARIES userver::kafka-utest
    DEPENDS core
)

target_compile_options(${PROJECT_NAME} PRIVATE "-Wno-ignored-qualifiers")

if(KAFKA_CPM)
    message(STATUS "Including from wrapper ${CMAKE_CURRENT_SOURCE_DIR}/wrapper/include") 
    target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/wrapper/include")
endif()

# ...

@apolukhin
Copy link
Member

LGTM

@robot-magpie
Copy link

robot-magpie bot commented Nov 20, 2025

Many thanks for the PR! @apolukhin is now importing your pull request into our internal upstream repository.

@robot-magpie
Copy link

robot-magpie bot commented Nov 20, 2025

✅ This pull request is being closed because it has been successfully merged into our internal monorepository.
Your changes will be pushed to this repository soon. Thank you for your contribution!

@robot-magpie robot-magpie bot closed this Nov 20, 2025
robot-piglet pushed a commit that referenced this pull request Nov 20, 2025
Causes build to fail, with a typical error message about the missing header.
```cmake
cmake_minimum_required(VERSION 3.14)
project(XXX LANGUAGES CXX)

set(USERVER_PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/submodules/userver")
if(EXISTS ${USERVER_PROJECT_DIR})
	add_subdirectory(${USERVER_PROJECT_DIR})
else()
	message(FATAL_ERROR "Unable to locate userver in the submodules directory")
endif()

file(GLOB_RECURSE XXX_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
add_executable(${PROJECT_NAME} ${XXX_SRC_FILES})
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)

userver_setup_environment()
target_link_libraries(${PROJECT_NAME} PUBLIC userver::core userver::kafka)
```
```cpp
// src/main.cpp

#include <userver/components/minimal_server_component_list.hpp>
#include <userver/utils/daemon_run.hpp>

int main(int argc, char* argv[])
{
	auto components_list = userver::components::MinimalServerComponentList();
	return userver::utils::DaemonMain(argc, argv, components_list);
}
```
```sh
cmake -B build -DUSERVER_FEATURE_UTEST=OFF -DUSERVER_FEATURE_STACKTRACE=OFF -DUSERVER_FEATURE_KAFKA=ON
cmake --build build -- -j 16
```
```
submodules/userver/kafka/src/kafka/impl/holders.cpp:7:10: fatal error: librdkafka/rdkafka_mock.h: No such file or directory
    7 | #include <librdkafka/rdkafka_mock.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
```
63de2c9 adds the include directive for this header, but the wrapper header `rdkafka_mock.h` itself was not provided.

---

Pull Request resolved: #1060
commit_hash:c6252833a9b354bf2fad7d9d47d97ea5c23fd55b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants