Dear all,

I have a Matlab function vmu2png.m (this is the source code), and I'd like
to compile it into an executable/binary using a CMake project (cmake
2.8.11.2 on linux).

To compile the function, I need to run Matlab's mcc program, e.g. "mcc
-m vmu2png.m" from CMake. This will produce two files: run_vmu2png.sh and
vmu2png.

So far, I have managed to do it with add_custom_command() and
add_custom_target(), but this makes the function compile every time I use
"make", regardless of whether vmu2png.m has been modified.

My code is

  # vmu2png
  add_custom_command(
    OUTPUT  run_vmu2png.sh vmu2png
    COMMAND ${MATLAB_ROOT}/bin/mcc
    ARGS    -m vmu2png.m
    DEPENDS vmu2png.m
    COMMENT "Compiling vmu2png.m into a binary"
    )
  add_custom_target(do_vmu2png ALL
    DEPENDS run_vmu2png.sh vmu2png
    SOURCES vmu2png.m
    )

If I remove ALL from add_custom_target(), then this compilation never
happens.

Is there a way to integrate this kind of compilation nicely with CMake?
That is, I'd like it to happen only when run_vmu2png.sh or vmu2png are
missing, or when the source file has been modified.

Best regards,

Ramon.



-- 
Dr. Ramón Casero Cañas

Institute of Biomedical Engineering
Department of Engineering Science, University of Oxford
Old Road Campus Research Building, Headington
Oxford
OX3 7DQ
UK

tlf         +44 (0) 1865 617716
twitter   @Ramon_Casero
web      http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas/
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to