@@ -25,25 +25,6 @@ else()
2525 set (VCPKG_PREFIX ${CMAKE_BINARY_DIR} /vcpkg)
2626 endif ()
2727
28- # Define custom triplets for vcpkg
29- if (APPLE )
30- # On Mac, there is a conflict between libcurl and the version in MATLAB, so
31- # use libcurl as a shared library and load the MATLAB version at runtime
32- # run uname -m to determine whether arm64 or x86_64
33- exec_program (uname ARGS -m OUTPUT_VARIABLE MAC_HOST_SYSTEM)
34- set (VCPKG_OTEL_TRIPLET ${MAC_HOST_SYSTEM} -osx-otel-matlab)
35- set (VCPKG_OVERLAY_TRIPLETS ${CMAKE_SOURCE_DIR} /cmake/vcpkg_triplets)
36- set (VCPKG_TARGET_TRIPLET ${VCPKG_OTEL_TRIPLET} )
37- set (TRIPLET_DEFINITIONS -DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET} )
38- elseif (WIN32 )
39- # On Windows, there is a conflict between abseil_dll.dll and the version used by Simulink.
40- # The shared library doesn't seem ABI stable and different versions cannot be used interchangeably.
41- # To sidestep the problem, use static library.
42- set (VCPKG_OVERLAY_TRIPLETS ${CMAKE_SOURCE_DIR} /cmake/vcpkg_triplets)
43- set (VCPKG_TARGET_TRIPLET x64-windows-otel-matlab)
44- set (TRIPLET_DEFINITIONS -DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET} )
45- endif ()
46-
4728 set (VCPKG_FETCH_CONTENT_NAME vcpkg)
4829 set (VCPKG_GIT_REPOSITORY "https://github.com/microsoft/vcpkg.git" )
4930 set (VCPKG_GIT_TAG "fba75d0" )
@@ -68,6 +49,28 @@ if(NOT DEFINED VCPKG_INSTALLED_DIR)
6849 set (VCPKG_INSTALLED_DIR ${CMAKE_BINARY_DIR} /vcpkg_installed)
6950endif ()
7051
52+ # Define custom triplets for vcpkg
53+ if (APPLE )
54+ # On Mac, there is a conflict between libcurl and the version in MATLAB, so
55+ # use libcurl as a shared library and load the MATLAB version at runtime
56+ # run uname -m to determine whether arm64 or x86_64
57+ exec_program (uname ARGS -m OUTPUT_VARIABLE MAC_HOST_SYSTEM)
58+ set (VCPKG_OTEL_TRIPLET ${MAC_HOST_SYSTEM} -osx-otel-matlab)
59+ set (VCPKG_OVERLAY_TRIPLETS ${CMAKE_SOURCE_DIR} /cmake/vcpkg_triplets)
60+ set (VCPKG_TARGET_TRIPLET ${VCPKG_OTEL_TRIPLET} )
61+ set (TRIPLET_DEFINITIONS -DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET} )
62+ elseif (WIN32 )
63+ # On Windows, we use a custom triplet to work around two issues.
64+ # First, there is a conflict between abseil_dll.dll and the version used by Simulink.
65+ # The shared library doesn't seem ABI stable and different versions cannot be used interchangeably.
66+ # To sidestep the problem, use static library.
67+ # Second, define a preprocessor macro _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR to work around an invalid MEX file issue on GitHub
68+ # See https://github.com/mathworks/OpenTelemetry-Matlab/issues/130
69+ set (VCPKG_OVERLAY_TRIPLETS ${CMAKE_SOURCE_DIR} /cmake/vcpkg_triplets)
70+ set (VCPKG_TARGET_TRIPLET x64-windows-otel-matlab)
71+ set (TRIPLET_DEFINITIONS -DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET} )
72+ endif ()
73+
7174# ######################################
7275# Options
7376# ######################################
@@ -184,10 +187,18 @@ if(NOT DEFINED OTEL_CPP_INSTALLED_DIR)
184187
185188 set (OTEL_CPP_CXX_STANDARD 14)
186189
187- if (NOT APPLE OR SKIP_OTEL_CPP_PATCH)
188- set (patch_command "" )
190+ set (PATCHES_DIR ${CMAKE_SOURCE_DIR} /patches)
191+ if (SKIP_OTEL_CPP_PATCH)
192+ set (patch_comand "" )
193+ elseif (WIN32 )
194+ # Windows patch to add a preprocessor definition _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
195+ # See https://github.com/mathworks/OpenTelemetry-Matlab/issues/130
196+ set (patch_command git apply ${PATCHES_DIR} /otel-cpp-windows.patch)
197+ elseif (APPLE )
198+ # Mac patch to fix a linker issue when including gRPC exporter
199+ set (patch_command git apply ${PATCHES_DIR} /otel-cpp-mac.patch)
189200 else ()
190- set (patch_command git apply ${CMAKE_SOURCE_DIR} /otel-cpp.patch )
201+ set (patch_command "" )
191202 endif ()
192203
193204 ExternalProject_Add(
@@ -310,6 +321,12 @@ if(WITH_OTLP_GRPC)
310321 ${OTLP_EXPORTER_SOURCE_DIR} /OtlpGrpcLogRecordExporterProxy.cpp)
311322endif ()
312323
324+ if (WIN32 )
325+ # Add a preprocessor definition _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR to fix an invalid mex file issue on Windows.
326+ # See https://github.com/mathworks/OpenTelemetry-Matlab/issues/130
327+ add_compile_definitions (_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
328+ endif ()
329+
313330libmexclass_client_add_proxy_library(
314331 NAME ${OPENTELEMETRY_PROXY_LIBRARY_NAME}
315332 SOURCES ${OPENTELEMETRY_PROXY_SOURCES}
0 commit comments