Merge topic 'FindMatlab-simulink'

b36408a0 FindMatlab: Add notes for topic 'FindMatlab-simulink'
7274fd9c FindMatlab: Add EXECUTABLE, MODULE, and SHARED options to matlab_add_mex
ccd1341a FindMatlab: Add SIMULINK component
aaf4014c FindMatlab: Fix documentation
This commit is contained in:
Brad King 2016-09-26 09:06:26 -04:00 committed by CMake Topic Stage
commit d57a6493fc
2 changed files with 46 additions and 5 deletions

View File

@ -0,0 +1,4 @@
FindMatlab-simulink
-------------------
* The :module:`FindMatlab` module learned to find a SIMULINK component.

View File

@ -18,6 +18,8 @@
# * ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the MX, # * ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the MX,
# ENG and MAT libraries of Matlab # ENG and MAT libraries of Matlab
# * ``MAIN_PROGRAM`` the Matlab binary program. # * ``MAIN_PROGRAM`` the Matlab binary program.
# * ``MEX_COMPILER`` the MEX compiler.
# * ``SIMULINK`` the Simulink environment.
# #
# .. note:: # .. note::
# #
@ -819,12 +821,13 @@ endfunction()
# order to produce a MEX file. The final name of the produced output may be # order to produce a MEX file. The final name of the produced output may be
# specified, as well as additional link libraries, and a documentation entry # specified, as well as additional link libraries, and a documentation entry
# for the MEX file. Remaining arguments of the call are passed to the # for the MEX file. Remaining arguments of the call are passed to the
# :command:`add_library` command. # :command:`add_library` or :command:`add_executable` command.
# #
# :: # ::
# #
# matlab_add_mex( # matlab_add_mex(
# NAME <name> # NAME <name>
# [EXECUTABLE | MODULE | SHARED]
# SRC src1 [src2 ...] # SRC src1 [src2 ...]
# [OUTPUT_NAME output_name] # [OUTPUT_NAME output_name]
# [DOCUMENTATION file.txt] # [DOCUMENTATION file.txt]
@ -835,7 +838,7 @@ endfunction()
# ``NAME`` # ``NAME``
# name of the target. # name of the target.
# ``SRC`` # ``SRC``
# list of tje source files. # list of source files.
# ``LINK_TO`` # ``LINK_TO``
# a list of additional link dependencies. The target links to ``libmex`` # a list of additional link dependencies. The target links to ``libmex``
# by default. If ``Matlab_MX_LIBRARY`` is defined, it also # by default. If ``Matlab_MX_LIBRARY`` is defined, it also
@ -851,6 +854,10 @@ endfunction()
# mex file, and with extension `.m`. In that case, typing ``help <name>`` # mex file, and with extension `.m`. In that case, typing ``help <name>``
# in Matlab prints the documentation contained in this file. # in Matlab prints the documentation contained in this file.
# #
# ``MODULE`` or ``SHARED`` may be given to specify the type of library to be
# created. ``EXECUTABLE`` may be given to create an executable instead of
# a library. If no type is given explicitly, the type is ``SHARED``.
#
# The documentation file is not processed and should be in the following # The documentation file is not processed and should be in the following
# format: # format:
# #
@ -859,7 +866,7 @@ endfunction()
# % This is the documentation # % This is the documentation
# function ret = mex_target_output_name(input1) # function ret = mex_target_output_name(input1)
# #
function(matlab_add_mex ) function(matlab_add_mex)
if(NOT WIN32) if(NOT WIN32)
# we do not need all this on Windows # we do not need all this on Windows
@ -871,6 +878,7 @@ function(matlab_add_mex )
endif() endif()
set(options EXECUTABLE MODULE SHARED)
set(oneValueArgs NAME DOCUMENTATION OUTPUT_NAME) set(oneValueArgs NAME DOCUMENTATION OUTPUT_NAME)
set(multiValueArgs LINK_TO SRC) set(multiValueArgs LINK_TO SRC)
@ -885,11 +893,25 @@ function(matlab_add_mex )
set(${prefix}_OUTPUT_NAME ${${prefix}_NAME}) set(${prefix}_OUTPUT_NAME ${${prefix}_NAME})
endif() endif()
add_library(${${prefix}_NAME} if(${prefix}_EXECUTABLE)
SHARED add_executable(${${prefix}_NAME}
${${prefix}_SRC} ${${prefix}_SRC}
${${prefix}_DOCUMENTATION} ${${prefix}_DOCUMENTATION}
${${prefix}_UNPARSED_ARGUMENTS}) ${${prefix}_UNPARSED_ARGUMENTS})
else()
if(${prefix}_MODULE)
set(type MODULE)
else()
set(type SHARED)
endif()
add_library(${${prefix}_NAME}
${type}
${${prefix}_SRC}
${${prefix}_DOCUMENTATION}
${${prefix}_UNPARSED_ARGUMENTS})
endif()
target_include_directories(${${prefix}_NAME} PRIVATE ${Matlab_INCLUDE_DIRS}) target_include_directories(${${prefix}_NAME} PRIVATE ${Matlab_INCLUDE_DIRS})
if(DEFINED Matlab_MX_LIBRARY) if(DEFINED Matlab_MX_LIBRARY)
@ -1463,6 +1485,21 @@ if(_matlab_find_mat GREATER -1)
endif() endif()
unset(_matlab_find_mat) unset(_matlab_find_mat)
# Component Simulink
list(FIND Matlab_FIND_COMPONENTS SIMULINK _matlab_find_simulink)
if(_matlab_find_simulink GREATER -1)
find_path(
Matlab_SIMULINK_INCLUDE_DIR
simstruc.h
PATHS "${Matlab_ROOT_DIR}/simulink/include"
NO_DEFAULT_PATH
)
if(Matlab_SIMULINK_INCLUDE_DIR)
set(Matlab_SIMULINK_FOUND TRUE)
list(APPEND Matlab_INCLUDE_DIRS "${Matlab_SIMULINK_INCLUDE_DIR}")
endif()
endif()
unset(_matlab_find_simulink)
unset(_matlab_lib_dir_for_search) unset(_matlab_lib_dir_for_search)