From 20e93c3c930aaca5141a1e820cd3504fdccde0d8 Mon Sep 17 00:00:00 2001 From: Sarah Gilmore Date: Fri, 26 Apr 2024 15:23:52 -0400 Subject: [PATCH] Add comment explaining NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES flag --- libmexclass/cpp/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libmexclass/cpp/CMakeLists.txt b/libmexclass/cpp/CMakeLists.txt index b12ccd3..f0845e4 100644 --- a/libmexclass/cpp/CMakeLists.txt +++ b/libmexclass/cpp/CMakeLists.txt @@ -241,6 +241,22 @@ macro(libmexclass_client_add_mex_gateway) MatlabConfigure() + # By default matlab_add_mex automatically links the output MEX function + # against all MEX-related libraries. + # + # These include: + # - libmx + # - libmex + # - libMatlabDataArray + # - libMatlabEngine + # + # However, libMatlabEngine is only required for standalone C++ programs + # that utilize the MATLAB Engine. + # + # Avoid linking against libMatlabEngine by supplying the + # NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES flag and manually passing + # the required mex-related libraries as arguments for the LINK_TO parameter. + # matlab_add_mex(NAME ${LIBMEXCLASS_CLIENT_MEX_GATEWAY_NAME} SRC ${LIBMEXCLASS_CLIENT_MEX_GATEWAY_SOURCES} OUTPUT_NAME "gateway"