[CMake] Building Matlab Mex files and CMake 2.60

Benjamin Roy Benjamin.Roy at irisa.fr
Tue Jun 10 05:58:32 EDT 2008


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 ?

Thanks.

Benjamin



More information about the CMake mailing list