-
Notifications
You must be signed in to change notification settings - Fork 501
Description
Describe your environment
I'm on Windows 11 Pro (running in a virtual machine, if that matters). I'm using Visual Studio 2022 and CMake 4.0. I did a git clone of opentelemetry-cpp onto my machine under the V:\ drive, then ran the cmake configure, build, and install commands as listed here. I believe this is opentelemetry-cpp version 1.22.0, from the main branch.
Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.
I'm working on the Vega Strike project with several other developers. I'm trying to add opentelemetry-cpp instrumentation, outputting logs and traces to files on disk.
Our project contains multiple CMakeLists.txt files in different subdirectories, which get pulled in by the CMakeLists.txt in the root directory. I bring in opentelemetry-cpp, protobuf, and nlohmann-json in the root CMakeLists.txt, using the following block of code:
OPTION(USE_OPEN_TELEMETRY "Include and use opentelemetry-cpp" OFF)
IF (USE_OPEN_TELEMETRY)
SET(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBUGINFO "Debug")
SET(opentelemetry-cpp_DIR ${Vega_Strike_SOURCE_DIR}/lib/cmake/opentelemetry-cpp)
SET(nlohmann_json_DIR ${Vega_Strike_SOURCE_DIR}/share/cmake/nlohmann_json)
SET(Protobuf_DIR ${Vega_Strike_SOURCE_DIR}/cmake)
FIND_PACKAGE(Protobuf CONFIG)
# Use find_package to include OpenTelemetry C++
FIND_PACKAGE(opentelemetry-cpp CONFIG)
#check whether opentelemetry libraries found
IF (opentelemetry-cpp_FOUND)
MESSAGE(STATUS "Found opentelemetry libraries; preparing to use them")
ELSE ()
MESSAGE(WARNING "Did not find opentelemetry libraries; building without")
ENDIF ()
ELSE ()
MESSAGE(STATUS "USE_OPEN_TELEMETRY not set; building without")
ENDIF ()
# Set the default build type
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Release, RelWithDebInfo, Debug, Profiler" FORCE )
ENDIF (NOT CMAKE_BUILD_TYPE)
MESSAGE("** Build Type: ${CMAKE_BUILD_TYPE}")
The part that actually links to the opentelemetry-cpp libraries is under the engine/
subdirectory. Some relevant excerpts from that CMake file are as follows:
SET(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBUGINFO "Debug")
# ...
ADD_LIBRARY(vegastrike-engine_com OBJECT
${VEGA_GL_H_PATH}
${VEGA_GLU_H_PATH}
${VEGA_GLEXT_H_PATH}
${VEGA_GLUT_H_PATH}
${LIBPYTHON}
${LIBVS_LOGGING}
${LIBCONFIG}
${LIBDAMAGE}
${LIBRESOURCE}
${LIBCOMPONENT}
${LIBAI_SOURCES}
${LIBNET_SOURCES}
${LIBPYTHON_SOURCES}
${LIBSCRIPT_SOURCES}
)
#TARGET_COMPILE_FEATURES(vegastrike-engine_com PUBLIC cxx_std_11)
SET_PROPERTY(TARGET vegastrike-engine_com PROPERTY CXX_STANDARD 14)
SET_PROPERTY(TARGET vegastrike-engine_com PROPERTY CXX_STANDARD_REQUIRED TRUE)
SET_PROPERTY(TARGET vegastrike-engine_com PROPERTY CXX_EXTENSIONS ON)
set_property(TARGET vegastrike-engine_com PROPERTY POSITION_INDEPENDENT_CODE TRUE)
TARGET_COMPILE_DEFINITIONS(vegastrike-engine_com PUBLIC "BOOST_ALL_DYN_LINK" "$<$<CONFIG:Debug>:BOOST_DEBUG_PYTHON>")
IF (WIN32)
TARGET_COMPILE_DEFINITIONS(vegastrike-engine_com PUBLIC BOOST_USE_WINAPI_VERSION=0x0A00)
TARGET_COMPILE_DEFINITIONS(vegastrike-engine_com PUBLIC _WIN32_WINNT=0x0A00)
TARGET_COMPILE_DEFINITIONS(vegastrike-engine_com PUBLIC WINVER=0x0A00)
TARGET_COMPILE_DEFINITIONS(vegastrike-engine_com PUBLIC "$<$<CONFIG:Debug>:Py_DEBUG>")
ENDIF()
TARGET_INCLUDE_DIRECTORIES(vegastrike-engine_com SYSTEM PRIVATE ${VSE_TST_INCLUDES})
TARGET_INCLUDE_DIRECTORIES(vegastrike-engine_com PRIVATE
# VS engine headers
${Vega_Strike_SOURCE_DIR}
${Vega_Strike_SOURCE_DIR}/engine
${Vega_Strike_SOURCE_DIR}/engine/src
# Library Headers
${Vega_Strike_SOURCE_DIR}/libraries
# CMake Artifacts
${Vega_Strike_BINARY_DIR}
${Vega_Strike_BINARY_DIR}/src
${Vega_Strike_BINARY_DIR}/engine
${Vega_Strike_BINARY_DIR}/engine/src
)
IF (NEED_LINKING_AGAINST_LIBM)
TARGET_LINK_LIBRARIES(vegastrike-engine_com PRIVATE m)
ENDIF()
TARGET_LINK_LIBRARIES(vegastrike-engine_com PRIVATE
OpenGL::GL
OpenGL::GLU
GLUT::GLUT
${VSE_TST_LIBS}
${Boost_LIBRARIES}
${Python3_LIBRARIES}
)
IF (USE_OPEN_TELEMETRY)
TARGET_LINK_LIBRARIES(
vegastrike-engine_com PRIVATE
opentelemetry-cpp::api
opentelemetry-cpp::sdk
opentelemetry-cpp::common
opentelemetry-cpp::resources
opentelemetry-cpp::version
opentelemetry-cpp::logs
opentelemetry-cpp::trace
opentelemetry-cpp::metrics
opentelemetry-cpp::ext
opentelemetry-cpp::otlp_recordable
opentelemetry-cpp::proto
# opentelemetry-cpp::otlp_file_client
# opentelemetry-cpp::otlp_file_exporter
# opentelemetry-cpp::otlp_file_log_record_exporter
# opentelemetry-cpp::otlp_file_metric_exporter
opentelemetry-cpp::ostream_span_exporter
opentelemetry-cpp::ostream_metrics_exporter
opentelemetry-cpp::ostream_log_record_exporter
)
ENDIF ()
We specify our minimum CMake version as 3.21 in the root file, so CMake policy CMP0111 probably applies. Please also note that we are using CMake Presets in this project -- among other things, to hook into vcpkg as the dependency manager on Windows. We have a CMakePresets.json file, and I also have my own CMakeUserPresets.json, further customized.
I'm trying to build opentelemetry-cpp first, then install it in the Vega Strike source directory as the prefix. Then I try to build Vega Strike. The commands, run in Visual Studio 2022 PowerShell, are as follows:
Push-Location V:\opentelemetry-cpp\
Remove-Item -Recurse -Force .\build\
mkdir build && cd build
cmake -DBUILD_TESTING=OFF -DWITH_OTLP_FILE=ON -DWITH_STL=OFF -DWITH_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBUGINFO=Debug ..
cmake --build .
cmake --install . --config RelWithDebInfo --prefix ..\..\Vega-Strike-Engine-Source\
Set-Location V:\Vega-Strike-Engine-Source\
cmake --preset windows-ninja-pie-enabled-debug -DUSE_OPEN_TELEMETRY=1
What is the expected behavior?
CMake should finish configuring and generating the build system for Vega Strike successfully.
What is the actual behavior?
CMake fails with the following errors:
-- Configuring done (5.5s)
CMake Error in CMakeLists.txt:
IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::otlp_file_client" configuration "RelWithDebInfo".
CMake Error in CMakeLists.txt:
IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::otlp_file_exporter" configuration "RelWithDebInfo".
CMake Error in CMakeLists.txt:
IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::otlp_file_log_record_exporter" configuration
"RelWithDebInfo".
CMake Error in CMakeLists.txt:
IMPORTED_LOCATION not set for imported target
"opentelemetry-cpp::otlp_file_metric_exporter" configuration
"RelWithDebInfo".
-- Generating done (0.4s)
CMake Generate step failed. Build files cannot be regenerated correctly.
Additional context
I have no idea where RelWithDebInfo is even coming from at this point. And the otlp_file_... targets are mentioned in the error output even when I comment them out from my CMakeLists.txt. Very strange.
(I get the same error messages even when I build and install everything in Debug configuration, rather than RelWithDebInfo.)
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1
or me too
, to help us triage it. Learn more here.