[CMake] Building Matlab Mex files and CMake 2.60

Benjamin Roy Benjamin.Roy at irisa.fr
Thu Jun 12 09:34:10 EDT 2008


This was the problem, this Matlab Mexfile has dependencies to a shared 
library generated in another subdirectory of the build system.

I replace the line

TARGET bookread_exp_matlab

with

OUTPUT 
${MPTK_BINARY_DIR}/src/matlab/experimental/bookread_exp.${MEX_EXTENSION}
POST_BUILD

In order to ensure that the shared library is build before the Mexfile, 
and it work fine.

Thanks.

Benjamin


Brad King a écrit :
> Benjamin Roy wrote:
>  
>> Hello,
>>
>> I used to build Matlab Mex files using this kind of CMake files, the
>> build was working Both on linux and Windows (only with visual studio,
>> because gnumex is no longer support for MinGW and Matlab R2008):
>>
>> # SET MEX files extension
>> IF(UNIX)
>> IF(APPLE)
>> IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
>> SET(MEX_EXTENSION mexmaci)
>> ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
>> SET(MEX_EXTENSION mexmac)
>> ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
>> INCLUDE(FindMatlab)
>> FIND_PROGRAM(MEX_COMPILER mex)
>> ELSE(APPLE)
>> SET(MEX_EXTENSION mexglx)
>> INCLUDE(FindMatlab)
>> FIND_PROGRAM(MEX_COMPILER mex)
>> ENDIF(APPLE)
>> ELSE(UNIX)
>> IF(WIN32)
>> IF( CMAKE_CXX_COMPILER STREQUAL "cl")
>> SET(MEX_EXTENSION mexw32)
>> INCLUDE(FindMatlab)
>> FIND_PROGRAM(MEX_COMPILER mex)
>> MESSAGE("Please set mex compiler with Visual Studio using Matlab command
>> line and mex -setup command")
>> ELSE( CMAKE_CXX_COMPILER STREQUAL "cl")
>> MESSAGE("Matlab Mex files are only supported by MS Visual Studio")
>> ENDIF( CMAKE_CXX_COMPILER STREQUAL "cl")
>> ENDIF(WIN32)
>> ENDIF(UNIX)
>>
>> IF(MEX_COMPILER)
>>
>> ADD_CUSTOM_TARGET(bookread_exp_matlab ALL echo
>>        DEPENDS   
>> ${MPTK_BINARY_DIR}/src/matlab/experimental/bookread_exp.${MEX_EXTENSION}
>>  )
>>
>>
>> ADD_CUSTOM_COMMAND(
>>   TARGET bookread_exp_matlab
>>   COMMAND   ${MEX_COMPILER}
>>   ARGS      -O -DHAVE_FFTW3 -I${MATLAB_INCLUDE_DIR} -I${MPTK_BINARY_DIR}
>> -I${MPTK_SOURCE_DIR}/src/tinyxml/ -I/usr/include/ -I${MPTK_SOURCE_DIR}
>> -I${MPTK_SOURCE_DIR}/src/libdsp_windows/
>> -I${MPTK_SOURCE_DIR}/src/libmptk/
>> -I${MPTK_SOURCE_DIR}/src/matlab/experimental/classes/
>> -I${MPTK_SOURCE_DIR}/src/plugin/base/
>> -I${MPTK_SOURCE_DIR}/src/plugin/contrib/lam/ -I${FFTW3_INCLUDE_DIR}
>> -I${MPTK_BINARY_DIR}/src/libmptk/
>> ${MPTK_SOURCE_DIR}/src/matlab/experimental/bookread_exp.cpp
>> ${MPTK_SOURCE_DIR}/src/matlab/experimental/classes/mxBook.cpp
>> -L${MPTK_BINARY_DIR}/lib -lmptk
>>   COMMENT   "MEX"
>> )
>>
>> ENDIF(MEX_COMPILER)
>>
>> It was working fine till version 2.6.0. But now I ve got a make error:
>> make[2]: *** No rule to make target `src/matlab/bookread.mexglx', needed
>> by `src/matlab/CMakeFiles/bookread_matlab'.  Stop.
>> make[1]: *** [src/matlab/CMakeFiles/bookread_matlab.dir/all] Error 2
>> make: *** [all] Error 2
>>
>> Did i miss something basic ? And why such differences in make files
>> generated by CMake 2.6.0 and CMake 2.4.8 ?
>>     
>
> I can't even get the above example to work in 2.4.  It looks like this
> is a subdirectory of a larger build system.  Can you reproduce this
> problem in a self-contained example please?
>
> If I replace the line
>
>   TARGET bookread_exp_matlab
>
> with
>
>   OUTPUT 
> ${MPTK_BINARY_DIR}/src/matlab/experimental/bookread_exp.${MEX_EXTENSION}
>
> then it works in both 2.4 and 2.6.
>
> -Brad
>
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080612/c0236e19/attachment.htm>


More information about the CMake mailing list