diff --git a/exporters/fluentd/CMakeLists.txt b/exporters/fluentd/CMakeLists.txt index 646e29a4d..ca0d389c0 100644 --- a/exporters/fluentd/CMakeLists.txt +++ b/exporters/fluentd/CMakeLists.txt @@ -41,12 +41,16 @@ set(nlohmann_json_clone FALSE) if(nlohmann_json_FOUND) message("Using external nlohmann::json") else() - include(cmake/nlohmann-json.cmake) - set(nlohmann_json_clone TRUE) - set(nlohmann_json_SOURCE_DIR - "${CMAKE_SOURCE_DIR}/nlohmann_json/single_include") - include_directories(${nlohmann_json_SOURCE_DIR}) - message("nlohmann_json package was not found. Cloning from github") + if (MAIN_PROJECT) + include(cmake/nlohmann-json.cmake) + set(nlohmann_json_clone TRUE) + set(nlohmann_json_SOURCE_DIR + "${CMAKE_SOURCE_DIR}/nlohmann_json/single_include") + include_directories(${nlohmann_json_SOURCE_DIR}) + message("nlohmann_json package was not found. Cloning from github") + else() + message(FATAL_ERROR "nlohmann_json package was not found which is required for opentelemetry-cpp-fluentd. Please install it") + endif() endif() if(MAIN_PROJECT)