Quick tutorial on how to debug a C project built with CMake in Linux (should also work on Windows/Mac). CMake is an open-source, cross-platform tool that uses compiler and platform independent configuration files to generate native build tool files specific to your compiler and platform. The CMake Tools extension integrates Visual Studio Code and CMake to make it easy to configure, build, and debug your C project.
有很多 C 项目是使用 CMake 进行构建的， 用户首先会调用 cmake 生成 Makefile 文件，然后再调用 make 执行构建。. GNU Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files. GNU Make 可用于从源码生成 可执行文件 或 其他文件。. In VS Code, bring the cursor on the name of the workspace (Test CMake VSCode) and click on the « +folder » icon when it becomes visible Type « src ». Now highlight the subdirectory named « src » then click on the « +file » icon Finally type « main.cpp ».
Having trouble setting up PropWare with Visual Studio Code on a Windows 10 system(s)
The background is that a young sharp co-op student has been successfully producing propeller C/C++ code using Visual Studio Code for file generation and Propware from the command line to compile and download. We have been trying to get the same setup on my computer(s) following the guide on David Zemon's site using the information on the Getting Started page and the Download page (MS Windows section) but are unsuccessful in running cmake.
The PropWare is on the C drive (C:PropWare) as is the PropGCC (C:parallax). Attempted with SimpleIDE installed (C:Program Files (x86)SimpleIDE) and not installed.
The extensions (think should not influence command line operations?) installed in Visual Studio Code are:
The banner at the bottom of Visual Studio Code shows 'No Kit Selected'
The CMakeLists.txt file is as follows:
and the GettingStarted.cpp file is
There are two error messages associated with the GettingStarted.cpp file:
but unsure if they relate to the cmake problem.
Upon running cmake the error message (with an empty Bin directory) is as follows
The CMake files in the bin directory are attached.
With the caveat that i am essentially ignorant of all matters IDE and compiling, a few items in CMakeCache stood out:
In looking around for hints on CMake_Make_Program program errors, common problems appear to be absence of a compiler or undefined tool path neither of which seem to be the problem and absence of or undefined path for nmake.exe.. At some point in our trouble shooting i seem to recall an nmake.exe error but it has not recurred.
Unsure if there should be a value assigned after the ...:INTERNAL= statements or not.
Any advice or troubleshooting tips would be much appreciated.
Vscode C++ Cmake Linux
Vscode C++ Cmake Tutorial
Vscode C++ Cmake Tutorial
Hi @bruceg! Great to hear someone still finds PropWare useful.
The CMAKE_MAKE_PROGRAM variable defines the path to the middleman build system. You invoke CMake -> CMake generates Makefiles -> you invoke Make -> make invokes compiler/propeller-load/etc. There are multiple flavors of Make out there, so CMake needs to know what flavor you want to use so that it knows exactly how to generate the Makefiles.
It appears that the PropWare documentation still says that GNU Make is included with the Windows distributable... that's not true anymore. Hasn't been for a while. Sorry for the confusion. You'll need to pick a Make flavor yourself and get it installed and working. This has, for a long time, been the part that has given me the most trouble on Windows, and is no small part of why I gave up on actively maintaining PropWare (Windows users are the majority of users -> I don't like Windows -> Windows instructions are not as well tested -> majority of users find PropWare difficult to use -> I loose interest).
You can try this installable - I've had luck with it in the past. But I've also seen that one fail to work. No idea if it will work for you today or not. You could also try Ninja: https://github.com/ninja-build/ninja/releases. I remember doing some tests with it many years ago, and it worked fine, but it does prevent the 'debug' target from doing any good, so just be aware of that (Ninja tries to make your life 'easier' by hiding unnecessary compiler output, and the way PropWare is designed, Ninja doesn't know the difference between compiler output and propeller-load's/your program's output, so it all gets hidden). You could also try NMake - that's Microsoft's Make flavor. It comes bundled with full Visual Studio installations (not VSCode).
There's a version of GNU Make included in the MinGW package. That's a complicated mess I haven't poked at in a long while, but it might work.
And there's Cygwin. That should theoretically work quite nicely, since you just install Cygwin and then it has a package manager with the real version of GNU Make that you can install. I think I tested this some 7 or 8 years ago, but I don't remember at all whether or not it worked and if it did what (if any) issues I had to overcome. I would think it would work very well and very seamlessly, and that the only reason I don't recommend it in PropWare's documentation is because it runs contrary to my goal of making it as easy as Arduino (I don't like the idea that you should need to install Propware AND a compiler AND Cygwin AND Make).
If you can integrate VSCode with WSL (Windows Subsystem for Linux), that is by far the easiest way to get compilation working. You just follow all of the Linux instructions and it works wonderfully. The only trick might be getting the serial port to work through the WSL layer so you can actually program the board.... I haven't tried it in years, and certainly not since WSL2 became a thing.
Once you do have a flavor of Make installed, you'll need to make sure you pass the right string to CMake's -G flag. The 'Command-Line Build Tool Generators' section of this CMake docs page has the list of options available: https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#id9
Let me know how it goes. I'd be happy to help some more and maybe we can find a proper solution to PropWare + Make on Windows.
Thank you very much for your quick response, was just looking at the CMake-generator page pondering the depths of my ignorance when your post came through, so your explanation tied everything together perfectly. Went with GNU Make direct via the Make for Windows page and 'Setup program' package route. Other then having to manually put make on the Windows path it was straight forward. Will also give Cygwin a whirl on another machine and see how that goes and report back.
Thank you for PropWare and thanks again for your help (i appreciate your lack of enthusiasm for Windows, will get to Linux one day...),
Excellent! Glad you got it working. If you run into any issues, feel free to let me know either here in the forums or in the issue tracker. Or if any of the open issues are directly affecting you, let me know and I can probably get it closed out.
Vscode Cmake Download
Source for this extension is maintained with the source for
In order for this extension to work you must have
This extension contributes the following settings:
You can find known issues with