Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for launching matlab via CMake in setup-matlab@v2 #110

Open
traversaro opened this issue May 6, 2024 · 3 comments
Open

Support for launching matlab via CMake in setup-matlab@v2 #110

traversaro opened this issue May 6, 2024 · 3 comments

Comments

@traversaro
Copy link

Hello everyone, thanks a lot for work on MATLAB-related GitHub Actions.

I looked in updating the CI of my projects to setup-matlab@v2 (see robotology/idyntree#1181). As my project is a C++ library that also provides MATLAB bindings, all the tests are handled via CMake test infrastructure (see for example CMake's FindMatlab matlab_add_unit_test command). On setup-matlab@v1 everything worked fine, while on setup-matlab@v2 the test fail as matlab is not able to find the license.

The problem is similar to #89, but in my case I do not directly set the command used to launch the tests, as that is handled by CMake. I wonder if there is any workaround for launching matlab command using setup-matlab@v2 ? Thanks a lot in advance!

@mcafaro
Copy link
Member

mcafaro commented May 6, 2024

Hi @traversaro, like #89, we do not have an official solution for supporting this type of workflow yet.

In the meantime, you may be able to create an adapter script that translates the matlab command CMake is attempting to call into a run-matlab-command call.

For example, in your job log, I see CMake is attempting to call matlab -nodisplay -nodesktop -nojvm -batch SOME_COMMAND_HERE. You could potentially write a bash script named matlab that does something like this:

# Example: 
# matlab -nodisplay -nojvm -batch "disp hello"

# Treat the last arg as the command
# In the example: "disp hello"
cmd=${@: -1}

# Treat everything else but the last two args as args for run-matlab-command 
# In the example: -nodisplay -nojvm
args=${@:1:$#-2}

# Call run-matlab-command with the cmd and args
# In the example: ./run-matlab-command "disp hello" -nodisplay -nojvm 
run-matlab-command "$cmd" "$args"

Then you have to get CMake to call your version of matlab instead of the matlab in the MATLAB bin folder. I am not familiar enough with the FindMatlab module to know if it supports doing that.

Like I mentioned in #89 though: please note the "run-matlab-command" binary is undocumented and subject to change in the future.

@traversaro
Copy link
Author

Good idea, thanks! I was thinking on modifying the CMake build system to use run-matlab-command, but avoiding to modify the CMake script would be welcome.

Like I mentioned in #89 though: please note the "run-matlab-command" binary is undocumented and subject to change in the future.

Sure, thanks!

@mcafaro
Copy link
Member

mcafaro commented May 6, 2024

Interested to hear if you end up getting things working with v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants