summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Warren <s.warren@garvan.org.au>2018-09-26 05:17:40 (GMT)
committerBrad King <brad.king@kitware.com>2018-09-26 11:54:01 (GMT)
commit9a56ed3438f652ec526afabeab87e04f330e4724 (patch)
tree857d3e3d701bdc087d710b6a650b1116b987801c
parent6c57f6b347f2acf19ef043e38463ac03919594f3 (diff)
downloadCMake-9a56ed3438f652ec526afabeab87e04f330e4724.zip
CMake-9a56ed3438f652ec526afabeab87e04f330e4724.tar.gz
CMake-9a56ed3438f652ec526afabeab87e04f330e4724.tar.bz2
FindMatlab: Explicitly export mexFunction in MSVC
Fixes: #18391
-rw-r--r--Help/release/dev/FindMatlab-2018b.rst3
-rw-r--r--Modules/FindMatlab.cmake14
2 files changed, 17 insertions, 0 deletions
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