2021-04-02 11:20:12 +08:00
if ( GTWRAP_PYTHON_PACKAGE_DIR )
# packaged
set ( GTWRAP_PACKAGE_DIR "${GTWRAP_PYTHON_PACKAGE_DIR}" )
else ( )
set ( GTWRAP_PACKAGE_DIR ${ CMAKE_CURRENT_LIST_DIR } /.. )
2021-03-10 22:18:36 +08:00
endif ( )
2021-04-02 11:20:12 +08:00
# Macro which finds and configure Matlab before we do any wrapping.
macro ( find_and_configure_matlab )
find_package (
M a t l a b
C O M P O N E N T S M E X _ C O M P I L E R
R E Q U I R E D )
2021-03-10 22:18:36 +08:00
2021-04-02 11:20:12 +08:00
if ( NOT Matlab_MEX_COMPILER )
message (
F A T A L _ E R R O R
" C a n n o t f i n d M E X c o m p i l e r b i n a r y . P l e a s e c h e c k y o u r M a t l a b i n s t a l l a t i o n a n d e n s u r e M E X i n i n s t a l l e d a s w e l l . "
)
endif ( )
2021-03-10 22:18:36 +08:00
2021-04-02 11:20:12 +08:00
if ( WRAP_BUILD_TYPE_POSTFIXES )
set ( CURRENT_POSTFIX ${ CMAKE_${CMAKE_BUILD_TYPE_UPPER } _POSTFIX} )
endif ( )
2021-03-10 22:18:36 +08:00
2021-04-02 11:20:12 +08:00
# WRAP_MEX_BUILD_STATIC_MODULE is not for Windows - on Windows any static
# are already compiled into the library by the linker
if ( WRAP_MEX_BUILD_STATIC_MODULE AND WIN32 )
message ( FATAL_ERROR "WRAP_MEX_BUILD_STATIC_MODULE should not be set on Windows - the linker already automatically compiles in any dependent static libraries. To create a standalone toolbox pacakge, simply ensure that CMake finds the static versions of all dependent libraries (Boost, etc)." )
2021-03-10 22:18:36 +08:00
endif ( )
2021-04-02 11:20:12 +08:00
set ( MEX_COMMAND ${ Matlab_MEX_COMPILER } CACHE PATH "Path to MATLAB MEX compiler" )
set ( MATLAB_ROOT ${ Matlab_ROOT_DIR } CACHE PATH "Path to MATLAB installation root (e.g. /usr/local/MATLAB/R2012a)" )
# Try to automatically configure mex path from provided custom `bin` path.
if ( WRAP_CUSTOM_MATLAB_PATH )
set ( matlab_bin_directory ${ WRAP_CUSTOM_MATLAB_PATH } )
if ( WIN32 )
set ( mex_program_name "mex.bat" )
else ( )
set ( mex_program_name "mex" )
endif ( )
# Run find_program explicitly putting $PATH after our predefined program
# directories using 'ENV PATH' and 'NO_SYSTEM_ENVIRONMENT_PATH' - this prevents
# finding the LaTeX mex program (totally unrelated to MATLAB Mex) when LaTeX is
# on the system path.
find_program ( MEX_COMMAND ${ mex_program_name }
P A T H S $ { m a t l a b _ b i n _ d i r e c t o r y } E N V P A T H
N O _ D E F A U L T _ P A T H )
mark_as_advanced ( FORCE MEX_COMMAND )
# Now that we have mex, trace back to find the Matlab installation root
get_filename_component ( MEX_COMMAND "${MEX_COMMAND}" REALPATH )
get_filename_component ( mex_path "${MEX_COMMAND}" PATH )
if ( mex_path MATCHES ".*/win64$" )
get_filename_component ( MATLAB_ROOT "${mex_path}/../.." ABSOLUTE )
else ( )
get_filename_component ( MATLAB_ROOT "${mex_path}/.." ABSOLUTE )
endif ( )
2021-03-10 22:18:36 +08:00
endif ( )
2021-04-02 11:20:12 +08:00
endmacro ( )
2021-03-10 22:18:36 +08:00
# Consistent and user-friendly wrap function
2021-12-07 00:01:43 +08:00
function ( matlab_wrap interfaceHeader moduleName linkLibraries
2023-02-17 16:13:23 +08:00
e x t r a I n c l u d e D i r s e x t r a M e x F l a g s i g n o r e _ c l a s s e s u s e _ b o o s t _ s e r i a l i z a t i o n )
2021-04-02 11:20:12 +08:00
find_and_configure_matlab ( )
2021-12-07 00:01:43 +08:00
wrap_and_install_library ( "${interfaceHeader}" "${moduleName}" "${linkLibraries}"
2021-03-10 22:18:36 +08:00
" $ { e x t r a I n c l u d e D i r s } " " $ { e x t r a M e x F l a g s } "
2023-02-17 16:13:23 +08:00
" $ { i g n o r e _ c l a s s e s } " " $ { u s e _ b o o s t _ s e r i a l i z a t i o n } " )
2021-03-10 22:18:36 +08:00
endfunction ( )
# Wrapping function. Builds a mex module from the provided
# interfaceHeader. For example, for the interface header gtsam.h, this will
# build the wrap module 'gtsam'.
#
# Arguments:
#
# interfaceHeader: The relative path to the wrapper interface definition file.
2021-12-07 00:01:43 +08:00
# moduleName: The name of the wrapped module, e.g. gtsam
2021-03-10 22:18:36 +08:00
# linkLibraries: Any *additional* libraries to link. Your project library
# (e.g. `lba`), libraries it depends on, and any necessary MATLAB libraries will
# be linked automatically. So normally, leave this empty.
# extraIncludeDirs: Any *additional* include paths required by dependent libraries that have not
# already been added by include_directories. Again, normally, leave this empty.
# extraMexFlags: Any *additional* flags to pass to the compiler when building
# the wrap code. Normally, leave this empty.
# ignore_classes: List of classes to ignore in the wrapping.
2023-02-17 16:13:23 +08:00
# use_boost_serialization: Flag indicating whether to provide Boost-based serialization.
2021-12-07 00:01:43 +08:00
function ( wrap_and_install_library interfaceHeader moduleName linkLibraries
2023-02-17 16:13:23 +08:00
e x t r a I n c l u d e D i r s e x t r a M e x F l a g s i g n o r e _ c l a s s e s u s e _ b o o s t _ s e r i a l i z a t i o n )
2021-12-07 00:01:43 +08:00
wrap_library_internal ( "${interfaceHeader}" "${moduleName}" "${linkLibraries}"
2023-02-17 16:13:23 +08:00
" $ { e x t r a I n c l u d e D i r s } " " $ { e x t r a M e x F l a g s } " " $ { i g n o r e _ c l a s s e s } "
" $ { u s e _ b o o s t _ s e r i a l i z a t i o n } " )
2021-12-07 00:01:43 +08:00
install_wrapped_library_internal ( "${moduleName}" )
2021-03-10 22:18:36 +08:00
endfunction ( )
# Internal function that wraps a library and compiles the wrapper
2021-12-07 00:01:43 +08:00
function ( wrap_library_internal interfaceHeader moduleName linkLibraries extraIncludeDirs
2023-02-17 16:13:23 +08:00
e x t r a M e x F l a g s i g n o r e _ c l a s s e s u s e _ b o o s t _ s e r i a l i z a t i o n )
2021-03-10 22:18:36 +08:00
if ( UNIX AND NOT APPLE )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( mexModuleExt mexa64 )
else ( )
set ( mexModuleExt mexglx )
endif ( )
elseif ( APPLE )
2023-06-06 01:29:21 +08:00
check_cxx_compiler_flag ( "-arch arm64" arm64Supported )
if ( arm64Supported )
set ( mexModuleExt mexmaca64 )
else ( )
set ( mexModuleExt mexmaci64 )
endif ( )
2021-03-10 22:18:36 +08:00
elseif ( MSVC )
if ( CMAKE_CL_64 )
set ( mexModuleExt mexw64 )
else ( )
set ( mexModuleExt mexw32 )
endif ( )
endif ( )
# Wrap codegen interface usage: wrap interfacePath moduleName toolboxPath
# headerPath interfacePath : *absolute* path to directory of module interface
# file moduleName : the name of the module, interface file must be called
# moduleName.h toolboxPath : the directory in which to generate the wrappers
# headerPath : path to matlab.h
# Extract module name from interface header file name
get_filename_component ( interfaceHeader "${interfaceHeader}" ABSOLUTE )
get_filename_component ( modulePath "${interfaceHeader}" PATH )
# Paths for generated files
set ( generated_files_path "${PROJECT_BINARY_DIR}/wrap/${moduleName}" )
set ( generated_cpp_file "${generated_files_path}/${moduleName}_wrapper.cpp" )
set ( compiled_mex_modules_root "${PROJECT_BINARY_DIR}/wrap/${moduleName}_mex" )
message ( STATUS "Building wrap module ${moduleName}" )
# Set matlab.h in project
set ( matlab_h_path "${CMAKE_SOURCE_DIR}" )
# If building a static mex module, add all cmake-linked libraries to the
# explicit link libraries list so that the next block of code can unpack any
# static libraries
set ( automaticDependencies "" )
2021-12-07 00:01:43 +08:00
foreach ( lib ${ module } ${ linkLibraries } )
2021-03-10 22:18:36 +08:00
if ( TARGET "${lib}" )
get_target_property ( dependentLibraries ${ lib } INTERFACE_LINK_LIBRARIES )
# message("DEPENDENT LIBRARIES: ${dependentLibraries}")
if ( dependentLibraries )
list ( APPEND automaticDependencies ${ dependentLibraries } )
endif ( )
endif ( )
endforeach ( )
# Separate dependencies
set ( correctedOtherLibraries "" )
set ( otherLibraryTargets "" )
set ( otherLibraryNontargets "" )
set ( otherSourcesAndObjects "" )
2021-12-07 00:01:43 +08:00
foreach ( lib ${ module } ${ linkLibraries } ${ automaticDependencies } )
2021-03-10 22:18:36 +08:00
if ( TARGET "${lib}" )
if ( WRAP_MEX_BUILD_STATIC_MODULE )
get_target_property ( target_sources ${ lib } SOURCES )
list ( APPEND otherSourcesAndObjects ${ target_sources } )
else ( )
list ( APPEND correctedOtherLibraries ${ lib } )
list ( APPEND otherLibraryTargets ${ lib } )
endif ( )
else ( )
get_filename_component ( file_extension "${lib}" EXT )
get_filename_component ( lib_name "${lib}" NAME_WE )
if ( file_extension STREQUAL ".a" AND WRAP_MEX_BUILD_STATIC_MODULE )
# For building a static MEX module, unpack the static library and
# compile its object files into our module
file ( MAKE_DIRECTORY "${generated_files_path}/${lib_name}_objects" )
execute_process (
C O M M A N D a r - x " $ { l i b } "
W O R K I N G _ D I R E C T O R Y " $ { g e n e r a t e d _ f i l e s _ p a t h } / $ { l i b _ n a m e } _ o b j e c t s "
R E S U L T _ V A R I A B L E a r _ r e s u l t )
if ( NOT ar_result EQUAL 0 )
message ( FATAL_ERROR "Failed extracting ${lib}" )
endif ( )
# Get list of object files
execute_process (
C O M M A N D a r - t " $ { l i b } "
O U T P U T _ V A R I A B L E o b j e c t _ f i l e s
R E S U L T _ V A R I A B L E a r _ r e s u l t )
if ( NOT ar_result EQUAL 0 )
message ( FATAL_ERROR "Failed listing ${lib}" )
endif ( )
# Add directory to object files
string ( REPLACE "\n" ";" object_files_list "${object_files}" )
foreach ( object_file ${ object_files_list } )
get_filename_component ( file_extension "${object_file}" EXT )
if ( file_extension STREQUAL ".o" )
list ( APPEND otherSourcesAndObjects
" $ { g e n e r a t e d _ f i l e s _ p a t h } / $ { l i b _ n a m e } _ o b j e c t s / $ { o b j e c t _ f i l e } " )
endif ( )
endforeach ( )
else ( )
list ( APPEND correctedOtherLibraries ${ lib } )
list ( APPEND otherLibraryNontargets ${ lib } )
endif ( )
endif ( )
endforeach ( )
# Check libraries for conflicting versions built-in to MATLAB
set ( dependentLibraries "" )
if ( NOT "${otherLibraryTargets}" STREQUAL "" )
foreach ( target ${ otherLibraryTargets } )
get_target_property ( dependentLibrariesOne ${ target }
I N T E R F A C E _ L I N K _ L I B R A R I E S )
list ( APPEND dependentLibraries ${ dependentLibrariesOne } )
endforeach ( )
endif ( )
list ( APPEND dependentLibraries ${ otherLibraryNontargets } )
check_conflicting_libraries_internal ( "${dependentLibraries}" )
# Set up generation of module source file
file ( MAKE_DIRECTORY "${generated_files_path}" )
find_package ( PythonInterp ${ WRAP_PYTHON_VERSION } EXACT )
find_package ( PythonLibs ${ WRAP_PYTHON_VERSION } EXACT )
2022-07-05 02:55:39 +08:00
# Set the path separator for PYTHONPATH
if ( UNIX )
set ( GTWRAP_PATH_SEPARATOR ":" )
else ( )
set ( GTWRAP_PATH_SEPARATOR ";" )
endif ( )
2023-02-17 16:13:23 +08:00
# Set boost serialization flag for the python script call below.
if ( use_boost_serialization )
set ( _BOOST_SERIALIZATION "--use-boost-serialization" )
else ( use_boost_serialization )
set ( _BOOST_SERIALIZATION "" )
endif ( use_boost_serialization )
2021-03-10 22:18:36 +08:00
add_custom_command (
O U T P U T $ { g e n e r a t e d _ c p p _ f i l e }
D E P E N D S $ { i n t e r f a c e H e a d e r } $ { m o d u l e _ l i b r a r y _ t a r g e t } $ { o t h e r L i b r a r y T a r g e t s }
$ { o t h e r S o u r c e s A n d O b j e c t s }
C O M M A N D
$ { C M A K E _ C O M M A N D } - E e n v
" P Y T H O N P A T H = $ { G T W R A P _ P A C K A G E _ D I R } $ { G T W R A P _ P A T H _ S E P A R A T O R } $ E N V { P Y T H O N P A T H } "
2021-12-07 00:01:43 +08:00
$ { P Y T H O N _ E X E C U T A B L E } $ { M A T L A B _ W R A P _ S C R I P T } - - s r c " $ { i n t e r f a c e H e a d e r } "
2021-03-10 22:18:36 +08:00
- - m o d u l e _ n a m e $ { m o d u l e N a m e } - - o u t $ { g e n e r a t e d _ f i l e s _ p a t h }
2023-02-17 16:13:23 +08:00
- - t o p _ m o d u l e _ n a m e s p a c e s $ { m o d u l e N a m e } - - i g n o r e $ { i g n o r e _ c l a s s e s } $ { _ B O O S T _ S E R I A L I Z A T I O N }
2021-03-10 22:18:36 +08:00
V E R B A T I M
W O R K I N G _ D I R E C T O R Y $ { g e n e r a t e d _ f i l e s _ p a t h } )
# Set up building of mex module
string ( REPLACE ";" " " extraMexFlagsSpaced "${extraMexFlags}" )
string ( REPLACE ";" " " mexFlagsSpaced "${WRAP_BUILD_MEX_BINARY_FLAGS}" )
add_library (
$ { m o d u l e N a m e } _ m a t l a b _ w r a p p e r M O D U L E
$ { g e n e r a t e d _ c p p _ f i l e } $ { i n t e r f a c e H e a d e r } $ { o t h e r S o u r c e s A n d O b j e c t s } )
target_link_libraries ( ${ moduleName } _matlab_wrapper ${ correctedOtherLibraries } )
target_link_libraries ( ${ moduleName } _matlab_wrapper ${ moduleName } )
set_target_properties (
$ { m o d u l e N a m e } _ m a t l a b _ w r a p p e r
P R O P E R T I E S O U T P U T _ N A M E " $ { m o d u l e N a m e } _ w r a p p e r "
P R E F I X " "
S U F F I X " . $ { m e x M o d u l e E x t } "
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { c o m p i l e d _ m e x _ m o d u l e s _ r o o t } "
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { c o m p i l e d _ m e x _ m o d u l e s _ r o o t } "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { c o m p i l e d _ m e x _ m o d u l e s _ r o o t } "
C L E A N _ D I R E C T _ O U T P U T 1 )
set_property (
T A R G E T $ { m o d u l e N a m e } _ m a t l a b _ w r a p p e r
A P P E N D _ S T R I N G
P R O P E R T Y
C O M P I L E _ F L A G S
" $ { e x t r a M e x F l a g s S p a c e d } $ { m e x F l a g s S p a c e d } \ " - I $ { M A T L A B _ R O O T } / e x t e r n / i n c l u d e \ " - D M A T L A B _ M E X _ F I L E - D M X _ C O M P A T _ 3 2 "
)
set_property (
T A R G E T $ { m o d u l e N a m e } _ m a t l a b _ w r a p p e r
A P P E N D
P R O P E R T Y I N C L U D E _ D I R E C T O R I E S $ { e x t r a I n c l u d e D i r s } )
# Disable build type postfixes for the mex module - we install in different
# directories for each build type instead
foreach ( build_type ${ CMAKE_CONFIGURATION_TYPES } )
string ( TOUPPER "${build_type}" build_type_upper )
set_target_properties ( ${ moduleName } _matlab_wrapper
P R O P E R T I E S $ { b u i l d _ t y p e _ u p p e r } _ P O S T F I X " " )
endforeach ( )
# Set up platform-specific flags
if ( MSVC )
if ( CMAKE_CL_64 )
set ( mxLibPath "${MATLAB_ROOT}/extern/lib/win64/microsoft" )
else ( )
set ( mxLibPath "${MATLAB_ROOT}/extern/lib/win32/microsoft" )
endif ( )
target_link_libraries (
$ { m o d u l e N a m e } _ m a t l a b _ w r a p p e r " $ { m x L i b P a t h } / l i b m e x . l i b "
" $ { m x L i b P a t h } / l i b m x . l i b " " $ { m x L i b P a t h } / l i b m a t . l i b " )
set_target_properties ( ${ moduleName } _matlab_wrapper
P R O P E R T I E S L I N K _ F L A G S " / e x p o r t : m e x F u n c t i o n " )
set_property (
S O U R C E " $ { g e n e r a t e d _ c p p _ f i l e } "
A P P E N D
P R O P E R T Y C O M P I L E _ F L A G S " / b i g o b j " )
elseif ( APPLE )
2023-06-06 01:29:21 +08:00
check_cxx_compiler_flag ( "-arch arm64" arm64Supported )
if ( arm64Supported )
set ( mxLibPath "${MATLAB_ROOT}/bin/maca64" )
else ( )
set ( mxLibPath "${MATLAB_ROOT}/bin/maci64" )
endif ( )
2021-03-10 22:18:36 +08:00
target_link_libraries (
$ { m o d u l e N a m e } _ m a t l a b _ w r a p p e r " $ { m x L i b P a t h } / l i b m e x . d y l i b "
" $ { m x L i b P a t h } / l i b m x . d y l i b " " $ { m x L i b P a t h } / l i b m a t . d y l i b " )
endif ( )
# Hacking around output issue with custom command Deletes generated build
# folder
add_custom_target (
w r a p _ $ { m o d u l e N a m e } _ m a t l a b _ d i s t c l e a n
C O M M A N D c m a k e - E r e m o v e _ d i r e c t o r y $ { g e n e r a t e d _ f i l e s _ p a t h }
C O M M A N D c m a k e - E r e m o v e _ d i r e c t o r y $ { c o m p i l e d _ m e x _ m o d u l e s _ r o o t } )
endfunction ( )
# Internal function that installs a wrap toolbox
function ( install_wrapped_library_internal interfaceHeader )
2021-12-07 00:01:43 +08:00
get_filename_component ( module "${interfaceHeader}" NAME_WE )
set ( generated_files_path "${PROJECT_BINARY_DIR}/wrap/${module}" )
2021-03-10 22:18:36 +08:00
# NOTE: only installs .m and mex binary files (not .cpp) - the trailing slash
# on the directory name here prevents creating the top-level module name
# directory in the destination.
message ( STATUS "Installing Matlab Toolbox to ${WRAP_TOOLBOX_INSTALL_PATH}" )
if ( WRAP_BUILD_TYPE_POSTFIXES )
foreach ( build_type ${ CMAKE_CONFIGURATION_TYPES } )
string ( TOUPPER "${build_type}" build_type_upper )
if ( ${ build_type_upper } STREQUAL "RELEASE" )
set ( build_type_tag "" ) # Don't create release mode tag on installed
# directory
else ( )
set ( build_type_tag "${build_type}" )
endif ( )
# Split up filename to strip trailing '/' in WRAP_TOOLBOX_INSTALL_PATH if
# there is one
get_filename_component ( location "${WRAP_TOOLBOX_INSTALL_PATH}" PATH )
get_filename_component ( name "${WRAP_TOOLBOX_INSTALL_PATH}" NAME )
install (
D I R E C T O R Y " $ { g e n e r a t e d _ f i l e s _ p a t h } / "
D E S T I N A T I O N " $ { l o c a t i o n } / $ { n a m e } $ { b u i l d _ t y p e _ t a g } "
C O N F I G U R A T I O N S " $ { b u i l d _ t y p e } "
F I L E S _ M A T C H I N G
P A T T E R N " * . m " )
install (
T A R G E T S $ { m o d u l e N a m e } _ m a t l a b _ w r a p p e r
L I B R A R Y D E S T I N A T I O N " $ { l o c a t i o n } / $ { n a m e } $ { b u i l d _ t y p e _ t a g } "
C O N F I G U R A T I O N S " $ { b u i l d _ t y p e } "
R U N T I M E D E S T I N A T I O N " $ { l o c a t i o n } / $ { n a m e } $ { b u i l d _ t y p e _ t a g } "
C O N F I G U R A T I O N S " $ { b u i l d _ t y p e } " )
endforeach ( )
else ( )
install (
D I R E C T O R Y " $ { g e n e r a t e d _ f i l e s _ p a t h } / "
D E S T I N A T I O N $ { W R A P _ T O O L B O X _ I N S T A L L _ P A T H }
F I L E S _ M A T C H I N G
P A T T E R N " * . m " )
install (
T A R G E T S $ { m o d u l e N a m e } _ m a t l a b _ w r a p p e r
L I B R A R Y D E S T I N A T I O N $ { W R A P _ T O O L B O X _ I N S T A L L _ P A T H }
R U N T I M E D E S T I N A T I O N $ { W R A P _ T O O L B O X _ I N S T A L L _ P A T H } )
endif ( )
endfunction ( )
# Internal function to check for libraries installed with MATLAB that may
# conflict and prints a warning to move them if problems occur.
function ( check_conflicting_libraries_internal libraries )
if ( UNIX )
# Set path for matlab's built-in libraries
if ( APPLE )
2023-06-06 01:29:21 +08:00
check_cxx_compiler_flag ( "-arch arm64" arm64Supported )
if ( arm64Supported )
set ( mxLibPath "${MATLAB_ROOT}/bin/maca64" )
else ( )
set ( mxLibPath "${MATLAB_ROOT}/bin/maci64" )
endif ( )
2021-03-10 22:18:36 +08:00
else ( )
if ( CMAKE_CL_64 )
set ( mxLibPath "${MATLAB_ROOT}/bin/glnxa64" )
else ( )
set ( mxLibPath "${MATLAB_ROOT}/bin/glnx86" )
endif ( )
endif ( )
# List matlab's built-in libraries
file (
G L O B m a t l a b L i b s
R E L A T I V E " $ { m x L i b P a t h } "
" $ { m x L i b P a t h } / l i b * " )
# Convert to base names
set ( matlabLibNames "" )
foreach ( lib ${ matlabLibs } )
get_filename_component ( libName "${lib}" NAME_WE )
list ( APPEND matlabLibNames "${libName}" )
endforeach ( )
# Get names of link libraries
set ( linkLibNames "" )
foreach ( lib ${ libraries } )
string ( FIND "${lib}" "/" slashPos )
if ( NOT slashPos EQUAL -1 )
# If the name is a path, just get the library name
get_filename_component ( libName "${lib}" NAME_WE )
list ( APPEND linkLibNames "${libName}" )
else ( )
# It's not a path, so see if it looks like a filename
get_filename_component ( ext "${lib}" EXT )
if ( NOT "${ext}" STREQUAL "" )
# It's a filename, so get the base name
get_filename_component ( libName "${lib}" NAME_WE )
list ( APPEND linkLibNames "${libName}" )
else ( )
# It's not a filename so it must be a short name, add the "lib" prefix
list ( APPEND linkLibNames "lib${lib}" )
endif ( )
endif ( )
endforeach ( )
# Remove duplicates
list ( REMOVE_DUPLICATES linkLibNames )
set ( conflictingLibs "" )
foreach ( lib ${ linkLibNames } )
list ( FIND matlabLibNames "${lib}" libPos )
if ( NOT libPos EQUAL -1 )
if ( NOT conflictingLibs STREQUAL "" )
set ( conflictingLibs "${conflictingLibs}, " )
endif ( )
set ( conflictingLibs "${conflictingLibs}${lib}" )
endif ( )
endforeach ( )
if ( NOT "${conflictingLibs}" STREQUAL "" )
message (
W A R N I N G
" T h e p r o j e c t l i n k s t o t h e l i b r a r i e s [ $ { c o n f l i c t i n g L i b s } ] o n y o u r s y s t e m , b u t "
" M A T L A B i s d i s t r i b u t e d w i t h i t s o w n v e r s i o n s o f t h e s e l i b r a r i e s w h i c h m a y c o n f l i c t . "
" I f y o u g e t s t r a n g e e r r o r s o r c r a s h e s w i t h t h e M A T L A B w r a p p e r , m o v e t h e s e "
" l i b r a r i e s o u t o f M A T L A B ' s b u i l t - i n l i b r a r y d i r e c t o r y , w h i c h i s $ { m x L i b P a t h } o n "
" y o u r s y s t e m . M A T L A B w i l l u s u a l l y s t i l l w o r k w i t h t h e s e l i b r a r i e s m o v e d a w a y , b u t "
" i f n o t , y o u ' l l h a v e t o c o m p i l e t h e s t a t i c M A T L A B w r a p p e r m o d u l e . "
)
endif ( )
endif ( )
endfunction ( )
# Helper function to install MATLAB scripts and handle multiple build types
# where the scripts should be installed to all build type toolboxes
function ( install_matlab_scripts source_directory patterns )
set ( patterns_args "" )
set ( exclude_patterns "" )
foreach ( pattern ${ patterns } )
list ( APPEND patterns_args PATTERN "${pattern}" )
endforeach ( )
if ( WRAP_BUILD_TYPE_POSTFIXES )
foreach ( build_type ${ CMAKE_CONFIGURATION_TYPES } )
string ( TOUPPER "${build_type}" build_type_upper )
if ( ${ build_type_upper } STREQUAL "RELEASE" )
set ( build_type_tag "" ) # Don't create release mode tag on installed
# directory
else ( )
set ( build_type_tag "${build_type}" )
endif ( )
# Split up filename to strip trailing '/' in WRAP_TOOLBOX_INSTALL_PATH if
# there is one
get_filename_component ( location "${WRAP_TOOLBOX_INSTALL_PATH}" PATH )
get_filename_component ( name "${WRAP_TOOLBOX_INSTALL_PATH}" NAME )
install (
D I R E C T O R Y " $ { s o u r c e _ d i r e c t o r y } "
D E S T I N A T I O N " $ { l o c a t i o n } / $ { n a m e } $ { b u i l d _ t y p e _ t a g } "
C O N F I G U R A T I O N S " $ { b u i l d _ t y p e } "
F I L E S _ M A T C H I N G $ { p a t t e r n s _ a r g s }
P A T T E R N " $ { e x c l u d e _ p a t t e r n s } " E X C L U D E )
endforeach ( )
else ( )
install (
D I R E C T O R Y " $ { s o u r c e _ d i r e c t o r y } "
D E S T I N A T I O N " $ { W R A P _ T O O L B O X _ I N S T A L L _ P A T H } "
F I L E S _ M A T C H I N G $ { p a t t e r n s _ a r g s }
P A T T E R N " $ { e x c l u d e _ p a t t e r n s } " E X C L U D E )
endif ( )
endfunction ( )