MantisBT - CMake
View Issue Details
0008207CMakeModulespublic2008-12-02 05:092015-11-02 09:15
Tom Vercauteren 
Raffi Enficiaud 
normalminoralways
closedfixed 
CMake-2-6 
CMake 3.3CMake 3.3 
0008207: FindMatlab is not flexible enough - patch included
The current FindMatlab.cmake module has several hard-coded paths that can not be overridden by the user.

Also the current module does not look for the mat library.
Attached is a new version of the FindMatlab.cmake module that looks for the mat library and allows the user to manually specify the MATLAB_ROOT variable.
No tags attached.
? FindMatlab.cmake (3,273) 2008-12-02 05:09
https://public.kitware.com/Bug/file/1884/FindMatlab.cmake
? FindMatlab-rwp.cmake (4,357) 2009-01-12 06:00
https://public.kitware.com/Bug/file/1985/FindMatlab-rwp.cmake
? MatlabMexMacro.cmake (3,055) 2010-05-19 05:26
https://public.kitware.com/Bug/file/3128/MatlabMexMacro.cmake
? MatlabMakeMacros.cmake (7,880) 2011-05-23 11:47
https://public.kitware.com/Bug/file/3890/MatlabMakeMacros.cmake
Issue History
2008-12-02 05:09Tom VercauterenNew Issue
2008-12-02 05:09Tom VercauterenFile Added: FindMatlab.cmake
2008-12-15 10:50Bill HoffmanStatusnew => assigned
2008-12-15 10:50Bill HoffmanAssigned To => Bill Hoffman
2009-01-12 06:00RW PenneyNote Added: 0014528
2009-01-12 06:00RW PenneyFile Added: FindMatlab-rwp.cmake
2010-05-14 11:30mbaumanNote Added: 0020739
2010-05-14 15:23Bill HoffmanNote Added: 0020741
2010-05-19 05:26Tom VercauterenNote Added: 0020790
2010-05-19 05:26Tom VercauterenFile Added: MatlabMexMacro.cmake
2011-05-23 02:50Tom VercauterenNote Added: 0026568
2011-05-23 11:47Ramón CaseroFile Added: MatlabMakeMacros.cmake
2011-05-23 11:52Ramón CaseroNote Added: 0026569
2011-05-23 12:00Ramón CaseroNote Edited: 0026569bug_revision_view_page.php?bugnote_id=26569#r328
2015-05-18 03:42Raffi EnficiaudNote Added: 0038758
2015-05-18 09:04Brad KingNote Added: 0038760
2015-05-18 09:05Brad KingAssigned ToBill Hoffman => Raffi Enficiaud
2015-05-18 09:05Brad KingStatusassigned => resolved
2015-05-18 09:05Brad KingResolutionopen => fixed
2015-05-18 09:05Brad KingFixed in Version => CMake 3.3
2015-05-18 09:05Brad KingTarget Version => CMake 3.3
2015-11-02 09:15Robert MaynardNote Added: 0039812
2015-11-02 09:15Robert MaynardStatusresolved => closed

Notes
(0014528)
RW Penney   
2009-01-12 06:00   
I too have been finding the existing FindMatlab.cmake within cmake-2.4 and cmake-2.6 to be rather restrictive, especially for cross-platform building of mex-files under win32/win64/linux environments.
In parallel with, and independently from Tom, I've been developing an alternative FindMatlab.cmake which I hope could be merged with the good ideas in Tom's scripts for use in a future version of cmake.
(0020739)
mbauman   
2010-05-14 11:30   
rwpenny's marvelous replacement has languished here for over a year. It works very well and is a vast improvement over the default FindMatlab.cmake. I would love to see it incorporated into CMake.
(0020741)
Bill Hoffman   
2010-05-14 15:23   
It needs a maintainer:

http://www.cmake.org/Wiki/CMake:Module_Maintainers [^]
(0020790)
Tom Vercauteren   
2010-05-19 05:26   
If a maintainer volunteers, it would also be nice to have a macro to build mex files from cmake. Something along the lines of the attached MatlabMexMacro.cmake should work.
(0026568)
Tom Vercauteren   
2011-05-23 02:50   
This issue is related to bug 0009240
(0026569)
Ramón Casero   
2011-05-23 11:52   
(edited on: 2011-05-23 12:00)
I have uploaded file MatlabMakeMacros.cmake. This file is a slightly derived work of the Matlab macros found in the source code provided with

Dru F., Fillard P., Vercauteren T., "An ITK Implementation of the Symmetric Log-Domain Diffeomorphic Demons Algorithm", Insight Journal, 2009 Jan-Jun

http://hdl.handle.net/10380/3060 [^]

Our small modification allows to compile a mex file for a Linux 64 bit architecture. Our file lives here

http://code.google.com/p/gerardus/source/browse/tags/release-0.4.0/matlab/MatlabMakeMacros.cmake [^]

The diff of our change is the following:

Index: MatlabMakeMacros.cmake
===================================================================
--- MatlabMakeMacros.cmake (revision 316)
+++ MatlabMakeMacros.cmake (revision 343)
@@ -62,7 +62,13 @@
     SD_APPEND_TARGET_PROPERTIES(${Target} COMPILE_FLAGS ${MATLAB_FLAGS})
     SET_TARGET_PROPERTIES(${Target} PROPERTIES LINK_FLAGS "/export:mexFunction")
   ELSE(MSVC)
- SET(MATLAB_FLAGS "-fPIC" "-D_GNU_SOURCE" "-pthread" "-D_FILE_OFFSET_BITS=64" "-DMX_COMPAT_32")
+ IF(CMAKE_SIZEOF_VOID_P MATCHES "4")
+ SET(MATLAB_FLAGS "-fPIC" "-D_GNU_SOURCE" "-pthread"
+ "-D_FILE_OFFSET_BITS=64" "-DMX_COMPAT_32")
+ ELSE(CMAKE_SIZEOF_VOID_P MATCHES "4")
+ SET(MATLAB_FLAGS "-fPIC" "-D_GNU_SOURCE" "-pthread"
+ "-D_FILE_OFFSET_BITS=64")
+ ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "4")
     SD_APPEND_TARGET_PROPERTIES(${Target} COMPILE_FLAGS ${MATLAB_FLAGS})
     
     IF(APPLE)

(0038758)
Raffi Enficiaud   
2015-05-18 03:42   
I believe the FindMatlab refactoring of the current CMake master branch (upcoming v3.3) addresses all those issues.
(0038760)
Brad King   
2015-05-18 09:04   
The changes mentioned in 0008207:0038758 are mostly in this commit:

 FindMatlab: Rewrite module and provide a usage API
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49c8dcf7 [^]
(0039812)
Robert Maynard   
2015-11-02 09:15   
Closing resolved issues that have not been updated in more than 4 months.