Skip to content

Commit ac894fb

Browse files
committed
Define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR preprocessor macro to work around invalid MEX file issue on Windows. Fixes #130
1 parent 4eb5d95 commit ac894fb

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

CMakeLists.txt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +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_OVERLAY_TRIPLETS="${VCPKG_OVERLAY_TRIPLETS}" -DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET})
38-
elseif(WIN32)
39-
# On Windows, we use a custom triplet to work around two issues.
40-
# First, there is a conflict between abseil_dll.dll and the version used by Simulink.
41-
# The shared library doesn't seem ABI stable and different versions cannot be used interchangeably.
42-
# To sidestep the problem, use static library.
43-
# Second, define a preprocessor macro _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR to work around an invalid MEX file issue on GitHub
44-
# See https://github.com/mathworks/OpenTelemetry-Matlab/issues/130
45-
set(VCPKG_OVERLAY_TRIPLETS ${CMAKE_SOURCE_DIR}/cmake/vcpkg_triplets)
46-
set(VCPKG_TARGET_TRIPLET x64-windows-otel-matlab)
47-
set(TRIPLET_DEFINITIONS -DVCPKG_OVERLAY_TRIPLETS="${VCPKG_OVERLAY_TRIPLETS}" -DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET})
48-
endif()
49-
5028
set(VCPKG_FETCH_CONTENT_NAME vcpkg)
5129
set(VCPKG_GIT_REPOSITORY "https://github.com/microsoft/vcpkg.git")
5230
set(VCPKG_GIT_TAG "fba75d0")
@@ -71,6 +49,28 @@ if(NOT DEFINED VCPKG_INSTALLED_DIR)
7149
set(VCPKG_INSTALLED_DIR ${CMAKE_BINARY_DIR}/vcpkg_installed)
7250
endif()
7351

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_OVERLAY_TRIPLETS="${VCPKG_OVERLAY_TRIPLETS}" -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_OVERLAY_TRIPLETS="${VCPKG_OVERLAY_TRIPLETS}" -DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET})
72+
endif()
73+
7474
# ######################################
7575
# Options
7676
# ######################################

0 commit comments

Comments
 (0)