lukka / run-cmake

GitHub Action to build C++ applications with CMake (CMakePresets.json), Ninja and vcpkg on GitHub.
MIT License
181 stars 19 forks source link

cmake -G Ninja fails on windows runner if CMakeLists.txt includes add_subdirectory() #47

Closed ugermann closed 3 years ago

ugermann commented 3 years ago

First, thanks for this great github action!

Second, I've been trying to get a windows runner to work with add_subdirector() in CMakeLists.txt, and have not been able get things to work with the Ninja generator. I've distilled things down to a minimal setup here: https://github.com/ugermann/run-cmake-fails-on-windows-runner/runs/2453647696?check_suite_focus=true. The problem is in line 34 of the output. Path prefix and the added subdirectory are concatenated in the wrong order.

I've been battling this for a few days now and have run out of ideas to try. Any suggestions?

lukka commented 3 years ago

@ugermann thanks for setting up a repro of the problem. Could you please re-run the same workflow with ACTION_STEPS_DEBUG set to true? The log of that run may shed some light about this.

Please compare your workflow with the one that validates the run-cmake action, here the last run for the 'basic scenario': https://github.com/lukka/CppBuildTasks-Validation/runs/2407441272

A notable difference is the usage of recent CMake, while your workflow is using whatever is installed already on the runner, which may be a little older and not compatible with the most recent Ninja. It should be possible to reproduce the same problem on Windows using the same version of CMake and Ninja.

Also, you may try using the get-cmake@latest action and see if using a recent CMake is working around this problem. Let me know!

XapaJIaMnu commented 3 years ago

@lukka the problem is also reproducible natively on Windows with whatever cmake version the latest visual studio and qtcreator ship. Using an altenrative generator eg -G "Visual Studio 16 2019" -A x64 avoids the issue.

lukka commented 3 years ago

@ugermann thanks for enabling debugging on the workflows.

Looks like the problem is manifesting when setting the OUTPUT_NAME target property in the CMakeLists.txt to a specific value. A ticket on CMake looks like worth in this case.

Let me know if there is anything that can be done on run-cmake side of things, thanks.

ugermann commented 3 years ago

Hi @lukka,

thanks for looking into this and your follow-up. I was planning to file an issue for cmake but it took me a while to figure out why my parameterization (for demo purposes) via CMAKE variables didn't work on the runner. Lesson learned: cmakeAppendedArgs is ignored by CMakeListsTxtBasic. I'm fairly new to github workflows and still feeling my way around them. I have a working minimal setup now that works for bug reporting.

Again, thanks for your help!

ugermann commented 3 years ago

The issue has now been reported here: https://gitlab.kitware.com/cmake/cmake/-/issues/22133