2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# Set up cache options
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								option ( GTSAM_MEX_BUILD_STATIC_MODULE  "Build MATLAB wrapper statically (increases build time)"  OFF ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set ( GTSAM_BUILD_MEX_BINARY_FLAGS  ""  CACHE  STRING  "Extra flags for running Matlab MEX compilation" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set ( GTSAM_TOOLBOX_INSTALL_PATH  ""  CACHE  PATH  "Matlab toolbox destination, blank defaults to CMAKE_INSTALL_PREFIX/gtsam_toolbox" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if ( NOT  GTSAM_TOOLBOX_INSTALL_PATH ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set ( GTSAM_TOOLBOX_INSTALL_PATH  "${CMAKE_INSTALL_PREFIX}/gtsam_toolbox" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								endif ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# GTSAM_MEX_BUILD_STATIC_MODULE is not for Windows - on Windows any static
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# are already compiled into the library by the linker
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if ( GTSAM_MEX_BUILD_STATIC_MODULE  AND  WIN32 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									message ( FATAL_ERROR  "GTSAM_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)." ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								endif ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# Try to automatically configure mex path
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if ( APPLE ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									file ( GLOB  matlab_bin_directories  "/Applications/MATLAB*/bin" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set ( mex_program_name  "mex" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								elseif ( WIN32 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									file ( GLOB  matlab_bin_directories  "C:/Program Files*/MATLAB/*/bin" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set ( mex_program_name  "mex.bat" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								else ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									file ( GLOB  matlab_bin_directories  "/usr/local/MATLAB/*/bin" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									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.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								list ( REVERSE  matlab_bin_directories )  # Reverse list so the highest version (sorted alphabetically) is preferred
  
						 
					
						
							
								
									
										
										
										
											2014-07-08 21:01:30 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								find_program ( MEX_COMMAND  ${ mex_program_name }  
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									P A T H S  $ { m a t l a b _ b i n _ d i r e c t o r i e s }  E N V  P A T H 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									N O _ D E F A U L T _ P A T H ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-07-08 21:01:30 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								mark_as_advanced ( FORCE  MEX_COMMAND ) 
  
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# Now that we have mex, trace back to find the Matlab installation root
  
						 
					
						
							
								
									
										
										
										
											2014-07-08 21:01:30 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								get_filename_component ( MEX_COMMAND  "${MEX_COMMAND}"  REALPATH ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								get_filename_component ( mex_path  "${MEX_COMMAND}"  PATH ) 
  
						 
					
						
							
								
									
										
										
										
											2019-07-10 05:11:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if ( mex_path  MATCHES  ".*/win64$" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									get_filename_component ( MATLAB_ROOT  "${mex_path}/../.."  ABSOLUTE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								else ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									get_filename_component ( MATLAB_ROOT  "${mex_path}/.."  ABSOLUTE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								endif ( ) 
  
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								set ( MATLAB_ROOT  "${MATLAB_ROOT}"  CACHE  PATH  "Path to MATLAB installation root (e.g. /usr/local/MATLAB/R2012a)" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# User-friendly wrapping function.  Builds a mex module from the provided
  
						 
					
						
							
								
									
										
										
										
											2014-02-20 04:43:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# interfaceHeader.  For example, for the interface header gtsam.h,
  
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# this will build the wrap module 'gtsam'.
  
						 
					
						
							
								
									
										
										
										
											2014-02-20 04:43:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# Arguments:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# interfaceHeader:  The relative path to the wrapper interface definition file.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# 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.
  
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								function ( wrap_and_install_library  interfaceHeader  linkLibraries  extraIncludeDirs  extraMexFlags ) 
  
						 
					
						
							
								
									
										
										
										
											2014-02-17 13:44:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									wrap_library_internal ( "${interfaceHeader}"  "${linkLibraries}"  "${extraIncludeDirs}"  "${mexFlags}" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									install_wrapped_library_internal ( "${interfaceHeader}" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								endfunction ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-19 02:43:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# Internal function that wraps a library and compiles the wrapper
  
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								function ( wrap_library_internal  interfaceHeader  linkLibraries  extraIncludeDirs  extraMexFlags ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if ( UNIX  AND  NOT  APPLE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( CMAKE_SIZEOF_VOID_P  EQUAL  8 ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											set ( mexModuleExt  mexa64 ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										else ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											set ( mexModuleExt  mexglx ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									elseif ( APPLE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set ( mexModuleExt  mexmaci64 ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									elseif ( MSVC ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( CMAKE_CL_64 ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											set ( mexModuleExt  mexw64 ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										else ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											set ( mexModuleExt  mexw32 ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									endif ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-12 07:16:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									# 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
 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-12 07:16:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    #  headerPath    : path to matlab.h
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									# Extract module name from interface header file name
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									get_filename_component ( interfaceHeader  "${interfaceHeader}"  ABSOLUTE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									get_filename_component ( modulePath  "${interfaceHeader}"  PATH ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									get_filename_component ( moduleName  "${interfaceHeader}"  NAME_WE ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-12 07:16:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									# Paths for generated files
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set ( generated_files_path  "${PROJECT_BINARY_DIR}/wrap/${moduleName}" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 10:01:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									set ( generated_cpp_file  "${generated_files_path}/${moduleName}_wrapper.cpp" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									set ( compiled_mex_modules_root  "${PROJECT_BINARY_DIR}/wrap/${moduleName}_mex" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-12 07:16:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									message ( STATUS  "Building wrap module ${moduleName}" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-12 07:16:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									# Find matlab.h in GTSAM
 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-12 07:16:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( ( "${PROJECT_NAME}"  STREQUAL  "gtsam" )  OR 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( " $ { P R O J E C T _ N A M E } "  S T R E Q U A L  " g t s a m _ u n s t a b l e " ) ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										set ( matlab_h_path  "${PROJECT_SOURCE_DIR}" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( NOT  GTSAM_INCLUDE_DIR ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											message ( FATAL_ERROR  "You must call find_package(GTSAM) before using wrap" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										list ( GET  GTSAM_INCLUDE_DIR  0  installed_includes_path ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set ( matlab_h_path  "${installed_includes_path}/wrap" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									endif ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									# 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  "" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									foreach ( lib  ${ moduleName }  ${ linkLibraries } ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 11:05:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									  #message("MODULE NAME: ${moduleName}")
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( TARGET  "${lib}" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            get_target_property ( dependentLibraries  ${ lib }  INTERFACE_LINK_LIBRARIES ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-11 20:23:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								           # message("DEPENDENT LIBRARIES:  ${dependentLibraries}")
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if ( dependentLibraries ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								               list ( APPEND  automaticDependencies  ${ dependentLibraries } ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        endif ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-11 20:23:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    endforeach ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 11:05:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ## CHRIS: Temporary fix. On my system the get_target_property above returned Not-found for gtsam module
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ## This needs to be fixed!!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if ( UNIX  AND  NOT  APPLE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      list ( APPEND  automaticDependencies  ${ Boost_SERIALIZATION_LIBRARY_RELEASE }  ${ Boost_FILESYSTEM_LIBRARY_RELEASE } 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-29 05:07:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $ { B o o s t _ S Y S T E M _ L I B R A R Y _ R E L E A S E }  $ { B o o s t _ T H R E A D _ L I B R A R Y _ R E L E A S E }  $ { B o o s t _ D A T E _ T I M E _ L I B R A R Y _ R E L E A S E } ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      if ( Boost_TIMER_LIBRARY_RELEASE  AND  NOT  GTSAM_DISABLE_NEW_TIMERS )  # Only present in Boost >= 1.48.0
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        list ( APPEND  automaticDependencies  ${ Boost_TIMER_LIBRARY_RELEASE }  ${ Boost_CHRONO_LIBRARY_RELEASE } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if ( GTSAM_MEX_BUILD_STATIC_MODULE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          #list(APPEND automaticDependencies -Wl,--no-as-needed -lrt)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 11:05:31 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    #message("AUTOMATIC DEPENDENCIES:  ${automaticDependencies}")
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ## CHRIS: End temporary fix
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									# Separate dependencies
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									set ( correctedOtherLibraries  "" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set ( otherLibraryTargets  "" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-17 13:44:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    set ( otherLibraryNontargets  "" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    set ( otherSourcesAndObjects  "" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									foreach ( lib  ${ moduleName }  ${ linkLibraries }  ${ automaticDependencies } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( TARGET  "${lib}" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										    if ( GTSAM_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 ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										else ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											get_filename_component ( file_extension  "${lib}"  EXT ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											get_filename_component ( lib_name  "${lib}"  NAME_WE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if ( file_extension  STREQUAL  ".a"  AND  GTSAM_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 ( COMMAND  ar  -x  "${lib}" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												                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 ( COMMAND  ar  -t  "${lib}" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																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  "${generated_files_path}/${lib_name}_objects/${object_file}" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												endforeach ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											else ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												list ( APPEND  correctedOtherLibraries  ${ lib } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									            list ( APPEND  otherLibraryNontargets  ${ lib } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            endif ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									endforeach ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-17 13:44:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Check libraries for conflicting versions built-in to MATLAB
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    set ( dependentLibraries  "" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if ( NOT  "${otherLibraryTargets}"  STREQUAL  "" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach ( target  ${ otherLibraryTargets } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            get_target_property ( dependentLibrariesOne  ${ target }  INTERFACE_LINK_LIBRARIES ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            list ( APPEND  dependentLibraries  ${ dependentLibrariesOne } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        endforeach ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    list ( APPEND  dependentLibraries  ${ otherLibraryNontargets } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    check_conflicting_libraries_internal ( "${dependentLibraries}" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									# Set up generation of module source file
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									file ( MAKE_DIRECTORY  "${generated_files_path}" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									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 } 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 10:51:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										D E P E N D S  $ { i n t e r f a c e H e a d e r }  w r a p  $ { 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 } 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        C O M M A N D  
 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-14 12:49:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            w r a p  - - m a t l a b 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            $ { m o d u l e P a t h } 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $ { m o d u l e N a m e }  
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $ { g e n e r a t e d _ f i l e s _ p a t h }  
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $ { m a t l a b _ h _ p a t h }  
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										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  "${GTSAM_BUILD_MEX_BINARY_FLAGS}" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 08:32:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									add_library ( ${ moduleName } _matlab_wrapper  MODULE  ${ generated_cpp_file }  ${ interfaceHeader }  ${ otherSourcesAndObjects } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									target_link_libraries ( ${ moduleName } _matlab_wrapper  ${ correctedOtherLibraries } ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-12 13:58:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									target_link_libraries ( ${ moduleName } _matlab_wrapper  ${ moduleName } ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 08:32:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									set_target_properties ( ${ moduleName } _matlab_wrapper  PROPERTIES 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 10:01:24 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										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 " 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										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 ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 08:32:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									set_property ( TARGET  ${ moduleName } _matlab_wrapper  APPEND_STRING  PROPERTY  COMPILE_FLAGS  " ${extraMexFlagsSpaced} ${mexFlagsSpaced} \" -I ${ MATLAB_ROOT } /extern/include\ " -DMATLAB_MEX_FILE -DMX_COMPAT_32" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set_property ( TARGET  ${ moduleName } _matlab_wrapper  APPEND  PROPERTY  INCLUDE_DIRECTORIES  ${ extraIncludeDirs } ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									# 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 ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 08:32:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										set_target_properties ( ${ moduleName } _matlab_wrapper  PROPERTIES  ${ build_type_upper } _POSTFIX  "" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									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 ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 08:32:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										target_link_libraries ( ${ moduleName } _matlab_wrapper  "${mxLibPath}/libmex.lib"  "${mxLibPath}/libmx.lib"  "${mxLibPath}/libmat.lib" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set_target_properties ( ${ moduleName } _matlab_wrapper  PROPERTIES  LINK_FLAGS  "/export:mexFunction" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										set_property ( SOURCE  "${generated_cpp_file}"  APPEND  PROPERTY  COMPILE_FLAGS  "/bigobj" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									elseif ( APPLE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set ( mxLibPath  "${MATLAB_ROOT}/bin/maci64" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 08:32:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										target_link_libraries ( ${ moduleName } _matlab_wrapper  "${mxLibPath}/libmex.dylib"  "${mxLibPath}/libmx.dylib"  "${mxLibPath}/libmat.dylib" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Hacking around output issue with custom command
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # Deletes generated build folder 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 08:32:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    add_custom_target ( wrap_ ${ moduleName } _matlab_distclean  
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									    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 ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-19 02:43:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# Internal function that installs a wrap toolbox
  
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								function ( install_wrapped_library_internal  interfaceHeader ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									get_filename_component ( moduleName  "${interfaceHeader}"  NAME_WE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set ( generated_files_path  "${PROJECT_BINARY_DIR}/wrap/${moduleName}" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    # 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 ${GTSAM_TOOLBOX_INSTALL_PATH}" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if ( GTSAM_BUILD_TYPE_POSTFIXES ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										foreach ( build_type  ${ CMAKE_CONFIGURATION_TYPES } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											string ( TOUPPER  "${build_type}"  build_type_upper ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-23 09:06:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( ${ build_type_upper }  STREQUAL  "RELEASE" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												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 GTSAM_TOOLBOX_INSTALL_PATH if there is one
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											get_filename_component ( location  "${GTSAM_TOOLBOX_INSTALL_PATH}"  PATH ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											get_filename_component ( name  "${GTSAM_TOOLBOX_INSTALL_PATH}"  NAME ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											install ( DIRECTORY  "${generated_files_path}/"  DESTINATION  "${location}/${name}${build_type_tag}"  CONFIGURATIONS  "${build_type}"  FILES_MATCHING  PATTERN  "*.m" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 08:32:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											install ( TARGETS  ${ moduleName } _matlab_wrapper 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												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 ( DIRECTORY  "${generated_files_path}/"  DESTINATION  ${ GTSAM_TOOLBOX_INSTALL_PATH }  FILES_MATCHING  PATTERN  "*.m" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-19 08:32:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										install ( TARGETS  ${ moduleName } _matlab_wrapper 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											L I B R A R Y  D E S T I N A T I O N  $ { G T S A M _ 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  $ { G T S A M _ T O O L B O X _ I N S T A L L _ P A T H } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								endfunction ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-19 02:43:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# Internal function to check for libraries installed with MATLAB that may conflict
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# and prints a warning to move them if problems occur.
  
						 
					
						
							
								
									
										
										
										
											2014-02-17 13:44:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function ( check_conflicting_libraries_internal  libraries ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if ( UNIX ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # Set path for matlab's built-in libraries
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if ( APPLE ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            set ( mxLibPath  "${MATLAB_ROOT}/bin/maci64" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        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 ( GLOB  matlabLibs  RELATIVE  "${mxLibPath}"  "${mxLibPath}/lib*" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        # 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 ( WARNING  "GTSAM links to the libraries [ ${conflictingLibs} ] on your system, but " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                " 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  G T S A M  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  G T S A M  M A T L A B  w r a p p e r  m o d u l e . " ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								endfunction ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# 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  "" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-21 10:44:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									set ( exclude_patterns  "" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if ( NOT  GTSAM_WRAP_SERIALIZATION ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									    set ( exclude_patterns  "testSerialization.m" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									foreach ( pattern  ${ patterns } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										list ( APPEND  patterns_args  PATTERN  "${pattern}" ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									endforeach ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if ( GTSAM_BUILD_TYPE_POSTFIXES ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										foreach ( build_type  ${ CMAKE_CONFIGURATION_TYPES } ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											string ( TOUPPER  "${build_type}"  build_type_upper ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-23 09:06:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( ${ build_type_upper }  STREQUAL  "RELEASE" ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												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 GTSAM_TOOLBOX_INSTALL_PATH if there is one
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											get_filename_component ( location  "${GTSAM_TOOLBOX_INSTALL_PATH}"  PATH ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											get_filename_component ( name  "${GTSAM_TOOLBOX_INSTALL_PATH}"  NAME ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-21 10:44:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											install ( DIRECTORY  "${source_directory}"  DESTINATION  "${location}/${name}${build_type_tag}"  CONFIGURATIONS  "${build_type}"  FILES_MATCHING  ${ patterns_args }  PATTERN  "${exclude_patterns}"  EXCLUDE ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										endforeach ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else ( ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-21 10:44:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										install ( DIRECTORY  "${source_directory}"  DESTINATION  "${GTSAM_TOOLBOX_INSTALL_PATH}"  FILES_MATCHING  ${ patterns_args }  PATTERN  "${exclude_patterns}"  EXCLUDE ) 
 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-23 02:01:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									endif ( ) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								endfunction ( )