Hi Kent,

A long time ago, I also submitted a patch to cmake to support mex file creation:
http://public.kitware.com/Bug/view.php?id=8207

It might have been pushed one step further in gerardus:
https://code.google.com/p/gerardus/source/browse/trunk/matlab/MatlabMakeMacros.cmake

It's closely related to what Matt proposed:
http://public.kitware.com/Bug/view.php?id=9240

At some point, I stopped using it because of issues with fPIC, static
libraries and linux 64 bit architecture (I was dealing not only with
ITK but a whole lot of different librairies as well)... It might need
some work to fix it but it might well still work if you are not using
libraries that Matlab also uses (e.g. QT).

Tom

On Tue, Nov 19, 2013 at 7:06 PM, Matt McCormick
<matt.mccorm...@kitware.com> wrote:
> Hi Kent,
>
> I wrote this [1][2] a long time ago, but I have not used it recently.
> There is an ITK example.
>
> Hope this helps,
> Matt
>
> [1] http://www.cmake.org/Wiki/CMake/MatlabMex
> [2] http://github.com/thewtex/matlab-itk-import/tree/master
>
> On Tue, Nov 19, 2013 at 12:59 PM, Williams, Norman K
> <norman-k-willi...@uiowa.edu> wrote:
>> Has anyone else come up with an elegant solution for this?
>>
>> If I want to call ITK from a Matlab MEX extension written in C++, I run
>> into problems with telling it the libraries with which to link.
>>
>> The ITK_LIBRARIES variable is a list of imported library targets which
>> CMake converts to actual library paths when it links a library or
>> executable.
>>
>> But to compile a MEX file, we're using a custom command along the lines of
>>
>>    add_custom_command(OUTPUT ${MEX_PREFIX}.${MATLAB_MEX_EXT}
>>                      COMMAND ${MATLAB_MEX_PATH} -cxx
>> ${CMAKE_CXX_FLAGS_Release} ${MEX_SRC_PATH}
>> ${ITK_INCLUDES} ${ITK_LIBRARIES}
>>                      -I${Teem_INCLUDE_DIR} -L${Teem_LIBRARY_DIR}  -lteem
>> ${ZLIB_LIBRARY}
>>                      DEPENDS ${MEX_SRC_PATH}
>>                      IMPLICIT_DEPENDS C ${MEX_SRC_PATH}
>>                      COMMENT "BUILDING MEX_FILE: ${MEX_SRC_PATH}" )
>>
>> But that doesn't work because CMake gives the target names in
>> ITK_LIBRARIES instead of the actual libraries.
>>
>> I tried this:
>>
>> find_package(ITK NO_MODULE REQUIRED)
>> include(${ITK_USE_FILE})
>>
>> set(ITK_LOCAL_LIBS)
>> foreach(lib ${ITK_LIBRARIES})
>>   get_target_property(_lib ${lib} IMPORTED_LOCATION)
>>
>>   list(APPEND ITK_LOCAL_LIBS ${_lib})endforeach()
>>
>> But all the IMPORTED_LOCATION for ITK libraries is _lib-NOTFOUND
>>
>>
>>
>> --
>> Kent Williams norman-k-willi...@uiowa.edu
>>
>>
>>
>>
>>
>>
>> ________________________________
>> Notice: This UI Health Care e-mail (including attachments) is covered by the 
>> Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential 
>> and may be legally privileged.  If you are not the intended recipient, you 
>> are hereby notified that any retention, dissemination, distribution, or 
>> copying of this communication is strictly prohibited.  Please reply to the 
>> sender that you have received the message in error, then delete it.  Thank 
>> you.
>> ________________________________
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-developers
>> _______________________________________________
>> Community mailing list
>> commun...@itk.org
>> http://public.kitware.com/cgi-bin/mailman/listinfo/community
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to