[CMake] FindMatlab tips?

Brian Davis bitminer at gmail.com
Fri Aug 6 11:34:35 EDT 2010


Fails miserably on Win32 (XP), Win7 64, Win Server 2008 64 too.  You'll find
as I have that the "find whatevers" are not all that they are cracked up to
be.  CUDA is another example.  find_package should really be named
attempt_to_find_package_and_when_you_can't_simply_tell_me_the_vars_to_set(
package_name )

I have found that FindWhatevers do not allow for a ordered specification of
search directories of where the build spec developer believes them to be on
their system.  If you look into these you will see a set of predefined
search directories that when things change are not up to date such as
C:\\Program Files\\MATLAB\\R2010a, C:\\Program Files\\MATLAB\\R2009b, etc
install dirs.

I have been doing the following:

--snip matlab_config.cmake--
macro( matlab_config )



    message( "MATLAB_INCLUDE_DIR = ${MATLAB_INCLUDE_DIR}" )
    #MATLAB_LIBRARIES
    #MATLAB_MEX_LIBRARY
    #MATLAB_MX_LIBRARY
    #MATLAB_ENG_LIBRARY

    if( BUILD_64BIT )
        set( LIB_DIR win64 )
        message( "BUILDING FOR 64 bit Windows" )

    else(BUILD_64BIT)
        set( LIB_DIR win32 )
        message( "BUILDING FOR 32 bit Windows" )

    endif(BUILD_64BIT)

    SET( MATLAB_ROOT_DIR "C:\\Program Files\\MATLAB\\R2010a" CACHE STRING ""
)
    SET( MATLAB_INCLUDE_DIR "${MATLAB_ROOT_DIR}\\extern\\include" CACHE
STRING "" FORCE )

    find_library(MATLAB_LIB_DIR libmx.lib PATHS ${MATLAB_ROOT_DIR}
${MATLAB_ROOT_DIR}/extern/lib/${LIB_DIR}/microsoft )
    message("MATLAB_LIB_DIR =
${MATLAB_ROOT_DIR}/extern/lib/${LIB_DIR}/microsoft" )
    message( "MATLAB_LIB_DIR = ${MATLAB_LIB_DIR}" )
    message( "matlab lib dir = ${MATLAB_ROOT_DIR}/extern/lib/${LIB_DIR}" )


    SET( MATLAB_LIBRARIES ${MATLAB_ROOT_DIR}/bin/${LIB_DIR} CACHE STRING ""
FORCE )
    SET( MATLAB_MEX_LIBRARY
${MATLAB_ROOT_DIR}/extern/lib/${LIB_DIR}/microsoft CACHE STRING "" FORCE )
    SET( MATLAB_MX_LIBRARY
${MATLAB_ROOT_DIR}/extern/lib/${LIB_DIR}/microsoft CACHE STRING "" FORCE )
    SET( MATLAB_ENG_LIBRARY
${MATLAB_ROOT_DIR}/extern/lib/${LIB_DIR}/microsoft CACHE STRING "" FORCE )

    INCLUDE_DIRECTORIES( ${MATLAB_INCLUDE_DIR} )

endmacro()


--end snip--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100806/d2630027/attachment.htm>


More information about the CMake mailing list