colcon / colcon-cmake

Extension for colcon to support CMake packages
http://colcon.readthedocs.io
Apache License 2.0
16 stars 25 forks source link

MSBuild not supported? #134

Open jporcher opened 8 months ago

jporcher commented 8 months ago

I'm trying to run colcon build with MSBuild command line tools (free) rather than Visual Studio (licenced). I'm trying to compile ROS2/Humble.

I could force this compiler to be used by adding --cmake-args "-GNMake Makefiles" -DCMAKE_BUILD_TYPE=Release, however, I encounter issues mainly because colcon code checks if 'Visual Studio' in generator: and if false code considers we are using MAkefile generator, while here it's NMake, which should be treated as 'Visual Studio'.

Is it intended that MSBuild is not supported? Why do we need the whole Visual Studio IDE to compile a project?

traversaro commented 8 months ago

Which specific issues are encountering? Did you try to use Ninja instead of NMake Makefiles? Furthermore, note that it should be perfectly fine to use msbuild to build the .sln files generated by the Visual Studio CMake generators.

jporcher commented 8 months ago

I did not try Ninja.

When I set "-GNMake Makefiles" -DCMAKE_BUILD_TYPE=Release, the error I get isNMAKE : fatal error U1065: option 'j' non valide I suspect it's because of some tests like if 'Visual Studio' in generator: in site-packages\colcon_cmake\task\cmake\build.py. _get_make_arguments ends up adding -j20 to build parameters, while this is not a valid NMake parameter.

Furthermore, note that it should be perfectly fine to use msbuild to build the .sln files generated by the Visual Studio CMake generators. But CMake is unable to generate .sln files using Visual Studio generator if Visual Studio is not installed. It reports "Generator Visual Studio 17 2022 could not find any instance of Visual Studio." Even if I sourced MSBuild environment before running colcon build.