From 9a56ed3438f652ec526afabeab87e04f330e4724 Mon Sep 17 00:00:00 2001 From: Sean Warren Date: Wed, 26 Sep 2018 15:17:40 +1000 Subject: FindMatlab: Explicitly export mexFunction in MSVC Fixes: #18391 --- Help/release/dev/FindMatlab-2018b.rst | 3 +++ Modules/FindMatlab.cmake | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Help/release/dev/FindMatlab-2018b.rst b/Help/release/dev/FindMatlab-2018b.rst index 7e17966..28758f1 100644 --- a/Help/release/dev/FindMatlab-2018b.rst +++ b/Help/release/dev/FindMatlab-2018b.rst @@ -4,3 +4,6 @@ FindMatlab-2018b * The :module:`FindMatlab` module gained new components ``ENGINE_LIBRARY`` and ``DATAARRAY_LIBRARY`` to request finding the Matlab C++ Engine and DataArray libraries respectively. + +* The :module:`FindMatlab` module now explicitly exports mexFunction in Visual + Studio. diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 4565076..da832ce 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -996,6 +996,20 @@ function(matlab_add_mex) endif() # documentation # entry point in the mex file + taking care of visibility and symbol clashes. + if (MSVC) + get_target_property( + _previous_link_flags + ${${prefix}_NAME} + LINK_FLAGS) + if(NOT _previous_link_flags) + set(_previous_link_flags) + endif() + + set_target_properties(${${prefix}_NAME} + PROPERTIES + LINK_FLAGS "${_previous_link_flags} /EXPORT:mexFunction") + endif() + if(WIN32) set_target_properties(${${prefix}_NAME} PROPERTIES -- cgit v0.12