FindMatlab's matlab_add_mex() does not accept EXCLUDE_FROM_ALL
Using CMake 3.12.0-rc1. If I add a Mex module with:
find_package(Matlab COMPONENTS MX_LIBRARY MEX_COMPILER)
matlab_add_mex(
NAME some_mex_module
SRC "mex_source"
)
This works fine, I get a target some_mex_module
. But if I don't want it to appear in the "all" target for a given generator, I would expect to do this:
find_package(Matlab COMPONENTS MX_LIBRARY MEX_COMPILER)
matlab_add_mex(
NAME some_mex_module
SRC "mex_source"
EXCLUDE_FROM_ALL
)
This is based on the documentation that says:
Remaining arguments of the call are passed to the
add_library()
oradd_executable()
command.
Instead I get this error:
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/FindMatlab.cmake:946 (add_library):
Cannot find source file:
EXCLUDE_FROM_ALL
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
.hpp .hxx .in .txx
Call Stack (most recent call first):
[...]/CMakeLists.txt:5 (matlab_add_mex)
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/FindMatlab.cmake:946 (add_library):
No SOURCES given to target: some_mex_module
Call Stack (most recent call first):
[...]/CMakeLists.txt:5 (matlab_add_mex)
Trying to force the termination of the argument list eg. by adding an empty LINK_TO
argument just results in EXCLUDE_FROM_ALL
being interpreted as an argument for that:
matlab_add_mex(
NAME some_mex_module
SRC "mex_source"
LINK_TO
EXCLUDE_FROM_ALL
)
...tries to link some_mex_module
against a non-existent EXCLUDE_FROM_ALL.lib
.