Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ else()
endif()
endif()
message(STATUS "Building for architecture ARCH=${ARCH}")

# Force C++17
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can not have that, this will break everybody.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to find an alternative

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcalff The only other way I can get it to compile with vs2022 is to add "-DWITH_STL=CXX14"
Other wise i get

warning STL4038: The contents of <string_view> are available only with C++17 or later.
C:\Users\Administrator\Git\opentelemetry-cpp\api\include\opentelemetry/std/string_view.h(18): error C2039: 'string_view': is not a member of 'std'

This is during stl build, nostd works without this (of course).

Copy link
Member

@owent owent Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use -DCMAKE_CXX_STANDARD=17 when running cmake command to use C++17 in your environment.

endif(MSVC)
# Autodetect vcpkg toolchain
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE
Expand Down
23 changes: 23 additions & 0 deletions ext/test/http/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

if(NOT GMOCK_LIB AND TARGET GTest::gmock)
set(GMOCK_LIB GTest::gmock)
elseif(MSVC)
# Explicitly specify that we consume GTest from shared library. The rest of
# code logic below determines whether we link Release or Debug flavor of the
# library. These flavors have different prefix on Windows, gmock and gmockd
# respectively.
add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1)
if(GMOCK_LIB)
# unset GMOCK_LIB to force find_library to redo the lookup, as the cached
# entry could cause linking to incorrect flavor of gmock and leading to
# runtime error.
unset(GMOCK_LIB CACHE)
endif()
endif()
if(NOT GMOCK_LIB)
if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug")
find_library(GMOCK_LIB gmockd PATH_SUFFIXES lib)
else()
find_library(GMOCK_LIB gmock PATH_SUFFIXES lib)
endif()
endif()

if(WITH_HTTP_CLIENT_CURL)
set(FILENAME curl_http_test)
add_compile_definitions(WITH_CURL)
Expand Down
18 changes: 11 additions & 7 deletions test_common/src/http/client/nosend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ if(${BUILD_TESTING})

set_target_properties(opentelemetry_http_client_nosend
PROPERTIES EXPORT_NAME opentelemetry_http_client_nosend)

if(MSVC)
if(NOT GMOCK_LIB AND TARGET GTest::gmock)
set(GMOCK_LIB GTest::gmock)
elseif(MSVC)
# Explicitly specify that we consume GTest from shared library. The rest of
# code logic below determines whether we link Release or Debug flavor of the
# library. These flavors have different prefix on Windows, gmock and gmockd
Expand All @@ -21,12 +22,15 @@ if(${BUILD_TESTING})
unset(GMOCK_LIB CACHE)
endif()
endif()
if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug")
find_library(GMOCK_LIB gmockd PATH_SUFFIXES lib)
else()
find_library(GMOCK_LIB gmock PATH_SUFFIXES lib)
endif()

if(NOT GMOCK_LIB)
if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug")
find_library(GMOCK_LIB gmockd PATH_SUFFIXES lib)
else()
find_library(GMOCK_LIB gmock PATH_SUFFIXES lib)
endif()
endif()

target_link_libraries(
opentelemetry_http_client_nosend opentelemetry_ext
opentelemetry_test_common ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES})
Expand Down
Loading