<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
This was the problem, this Matlab Mexfile has dependencies to a shared
library generated in another subdirectory of the build system.
<br>
<br>
I replace the line
<br>
<br>
TARGET bookread_exp_matlab
<br>
<br>
with
<br>
<br>
OUTPUT
${MPTK_BINARY_DIR}/src/matlab/experimental/bookread_exp.${MEX_EXTENSION}
<br>
POST_BUILD
<br>
<br>
In order to ensure that the shared library is build before the Mexfile,
and it work fine.
<br>
<br>
Thanks.
<br>
<br>
Benjamin
<br>
<br>
<br>
Brad King a écrit :
<br>
<blockquote type="cite">Benjamin Roy wrote:
<br>
<br>
<blockquote type="cite">Hello,
<br>
<br>
I used to build Matlab Mex files using this kind of CMake files, the
<br>
build was working Both on linux and Windows (only with visual studio,
<br>
because gnumex is no longer support for MinGW and Matlab R2008):
<br>
<br>
# SET MEX files extension
<br>
IF(UNIX)
<br>
IF(APPLE)
<br>
IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
<br>
SET(MEX_EXTENSION mexmaci)
<br>
ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
<br>
SET(MEX_EXTENSION mexmac)
<br>
ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
<br>
INCLUDE(FindMatlab)
<br>
FIND_PROGRAM(MEX_COMPILER mex)
<br>
ELSE(APPLE)
<br>
SET(MEX_EXTENSION mexglx)
<br>
INCLUDE(FindMatlab)
<br>
FIND_PROGRAM(MEX_COMPILER mex)
<br>
ENDIF(APPLE)
<br>
ELSE(UNIX)
<br>
IF(WIN32)
<br>
IF( CMAKE_CXX_COMPILER STREQUAL "cl")
<br>
SET(MEX_EXTENSION mexw32)
<br>
INCLUDE(FindMatlab)
<br>
FIND_PROGRAM(MEX_COMPILER mex)
<br>
MESSAGE("Please set mex compiler with Visual Studio using Matlab
command
<br>
line and mex -setup command")
<br>
ELSE( CMAKE_CXX_COMPILER STREQUAL "cl")
<br>
MESSAGE("Matlab Mex files are only supported by MS Visual Studio")
<br>
ENDIF( CMAKE_CXX_COMPILER STREQUAL "cl")
<br>
ENDIF(WIN32)
<br>
ENDIF(UNIX)
<br>
<br>
IF(MEX_COMPILER)
<br>
<br>
ADD_CUSTOM_TARGET(bookread_exp_matlab ALL echo
<br>
DEPENDS
${MPTK_BINARY_DIR}/src/matlab/experimental/bookread_exp.${MEX_EXTENSION}
<br>
)
<br>
<br>
<br>
ADD_CUSTOM_COMMAND(
<br>
TARGET bookread_exp_matlab
<br>
COMMAND ${MEX_COMPILER}
<br>
ARGS -O -DHAVE_FFTW3 -I${MATLAB_INCLUDE_DIR}
-I${MPTK_BINARY_DIR}
<br>
-I${MPTK_SOURCE_DIR}<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>src/tinyxml<span
class="moz-txt-tag">/</span></i> -I/usr/include/ -I${MPTK_SOURCE_DIR}
<br>
-I${MPTK_SOURCE_DIR}<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>src/libdsp_windows<span
class="moz-txt-tag">/</span></i>
<br>
-I${MPTK_SOURCE_DIR}<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>src/libmptk<span
class="moz-txt-tag">/</span></i>
<br>
-I${MPTK_SOURCE_DIR}<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>src/matlab/experimental/classes<span
class="moz-txt-tag">/</span></i>
<br>
-I${MPTK_SOURCE_DIR}<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>src/plugin/base<span
class="moz-txt-tag">/</span></i>
<br>
-I${MPTK_SOURCE_DIR}<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>src/plugin/contrib/lam<span
class="moz-txt-tag">/</span></i> -I${FFTW3_INCLUDE_DIR}
<br>
-I${MPTK_BINARY_DIR}<i class="moz-txt-slash"><span class="moz-txt-tag">/</span>src/libmptk<span
class="moz-txt-tag">/</span></i>
<br>
${MPTK_SOURCE_DIR}/src/matlab/experimental/bookread_exp.cpp
<br>
${MPTK_SOURCE_DIR}/src/matlab/experimental/classes/mxBook.cpp
<br>
-L${MPTK_BINARY_DIR}/lib -lmptk
<br>
COMMENT "MEX"
<br>
)
<br>
<br>
ENDIF(MEX_COMPILER)
<br>
<br>
It was working fine till version 2.6.0. But now I ve got a make error:
<br>
make[2]: *** No rule to make target `src/matlab/bookread.mexglx',
needed
<br>
by `src/matlab/CMakeFiles/bookread_matlab'. Stop.
<br>
make[1]: *** [src/matlab/CMakeFiles/bookread_matlab.dir/all] Error 2
<br>
make: *** [all] Error 2
<br>
<br>
Did i miss something basic ? And why such differences in make files
<br>
generated by CMake 2.6.0 and CMake 2.4.8 ?
<br>
</blockquote>
<br>
I can't even get the above example to work in 2.4. It looks like this
<br>
is a subdirectory of a larger build system. Can you reproduce this
<br>
problem in a self-contained example please?
<br>
<br>
If I replace the line
<br>
<br>
TARGET bookread_exp_matlab
<br>
<br>
with
<br>
<br>
OUTPUT
${MPTK_BINARY_DIR}/src/matlab/experimental/bookread_exp.${MEX_EXTENSION}
<br>
<br>
then it works in both 2.4 and 2.6.
<br>
<br>
-Brad
<br>
<br>
<br>
</blockquote>
<br>
</body>
</html>