I’ve searched online for how to, but I didn’t notice any documentation. I understand how to add python3 as an interpreter, but I’m new to compiled languages, and the “Binary application” choice confuses me. Furthermore, I’m not even certain whether it’s the correct one. (Additionally, which choice in the menu bar compiles it? – “Debug launch”?)
I want this so that I need not have to type g++ -std=gnu++20 -o ./output ./source.cpp in the konsole KPart panel anymore.
KDevelop is supposed to preconfigure things up for you as long as you have (a) the required build tools and (b) your CMakeLists.txt set up to generate a target correctly.
Then you should see a fourth option in that combobox that has the name of the executable target. That’s the right one. If it doesn’t appear, it is possible that there is something wrong in your CMakeLists.txt.
I hadn’t created a CMakeLists.txt file. I apologize; this is my first time using C++. I tried to verify that this wasn’t a KDE-related problem, but Google provided no useful answers for my queries. The W3C tutorial didn’t mention such a file.
@Herzenschein, do you know of any resources or can point to me to a basic CMakeLists.txt file already on my KDE installation? I ask solely because either I’m useless at using search engines, or the basic developer documentation for this topic needs some serious SEO.
Would be good if this instance of Discourse used whatever plugin or feature allows marking a response as the answer.
There’s currently no super satisfying tutorial that is both modern and explains the core functionality well IMO. There’s one on the way, but it will take a while to be finished.
This is the absolute minimum for a pure C++ project, following today’s best practices:
# No need to link any libraries (a.k.a. -l flag in g++/clang++)
You can also just pass the files directly through add_executable(), though it’s older and less flexible.
And this for Qt (and any other external libraries, like those from KDE Frameworks):
Widgets # If you need QtWidgets
Quick # If you need QtQuick
# Constructs the executable
# Adds source files to the executable
# We need linking here to actually use the Qt API
Both of these only compile things. If you need to install your app, you can use something like:
# a.k.a. /usr/local/bin by default,
# this can then be changed with CMAKE_INSTALL_PREFIX
# in the project's settings
To set the C++ standard to 20, use the project’s settings (CMake options) and add -DCMAKE_CXX_STANDARD=20 to the extra arguments. You could probably change the environment settings to that as well.
If you really need to enforce the C++ standard in the CMakeLists.txt file, use target_compile_features(maintargetexecutable PRIVATE cxx_std_20). Using set() is the old way.