summaryrefslogtreecommitdiff
path: root/Modules/FindMatlab.cmake
diff options
context:
space:
mode:
authorSilvio <silvio@traversaro.it>2022-04-03 17:25:12 +0200
committerBrad King <brad.king@kitware.com>2022-04-05 08:27:09 -0400
commit178cf34bdc5234e07442d0007c39e2d184b4261f (patch)
tree19c93e758675df831ef5abafa9099da368258f7d /Modules/FindMatlab.cmake
parentfff8f3bee92d9f139c48cdc194ca826447fc402a (diff)
downloadcmake-178cf34bdc5234e07442d0007c39e2d184b4261f.tar.gz
FindMatlab: Add NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES option to matlab_add_mex
Diffstat (limited to 'Modules/FindMatlab.cmake')
-rw-r--r--Modules/FindMatlab.cmake31
1 files changed, 21 insertions, 10 deletions
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 81bc4732fb..48ef5eb681 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -1020,6 +1020,7 @@ endfunction()
[LINK_TO target1 target2 ...]
[R2017b | R2018a]
[EXCLUDE_FROM_ALL]
+ [NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES]
[...]
)
@@ -1029,7 +1030,8 @@ endfunction()
list of source files.
``LINK_TO``
a list of additional link dependencies. The target links to ``libmex``
- and ``libmx`` by default.
+ and ``libmx`` by default, unless the
+ ``NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES`` option is passed.
``OUTPUT_NAME``
if given, overrides the default name. The default name is
the name of the target without any prefix and
@@ -1065,6 +1067,12 @@ endfunction()
This option has the same meaning as for :prop_tgt:`EXCLUDE_FROM_ALL` and
is forwarded to :command:`add_library` or :command:`add_executable`
commands.
+ ``NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES``
+ .. versionadded:: 3.24
+
+ This option permits to disable the automatic linking of MATLAB
+ libraries, so that only the libraries that are actually required can be
+ linked via the ``LINK_TO`` option.
The documentation file is not processed and should be in the following
format:
@@ -1091,7 +1099,7 @@ function(matlab_add_mex)
endif()
- set(options EXECUTABLE MODULE SHARED R2017b R2018a EXCLUDE_FROM_ALL)
+ set(options EXECUTABLE MODULE SHARED R2017b R2018a EXCLUDE_FROM_ALL NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES)
set(oneValueArgs NAME DOCUMENTATION OUTPUT_NAME)
set(multiValueArgs LINK_TO SRC)
@@ -1163,16 +1171,19 @@ function(matlab_add_mex)
target_include_directories(${${prefix}_NAME} PRIVATE ${Matlab_INCLUDE_DIRS})
- if(Matlab_HAS_CPP_API)
- if(Matlab_ENGINE_LIBRARY)
- target_link_libraries(${${prefix}_NAME} ${Matlab_ENGINE_LIBRARY})
- endif()
- if(Matlab_DATAARRAY_LIBRARY)
- target_link_libraries(${${prefix}_NAME} ${Matlab_DATAARRAY_LIBRARY})
+ if(NOT ${prefix}_NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES)
+ if(Matlab_HAS_CPP_API)
+ if(Matlab_ENGINE_LIBRARY)
+ target_link_libraries(${${prefix}_NAME} ${Matlab_ENGINE_LIBRARY})
+ endif()
+ if(Matlab_DATAARRAY_LIBRARY)
+ target_link_libraries(${${prefix}_NAME} ${Matlab_DATAARRAY_LIBRARY})
+ endif()
endif()
- endif()
- target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${${prefix}_LINK_TO})
+ target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY})
+ endif()
+ target_link_libraries(${${prefix}_NAME} ${${prefix}_LINK_TO})
set_target_properties(${${prefix}_NAME}
PROPERTIES
PREFIX ""