0

I know that KDevelop 4 was able to import CMake projects (hand written CMakeLists.txt not generated by KDevelop) ... but now after I installed ubuntu 18.04 it seems this is not possible anymore (the Project > Open/Import Project dialog simply refuse take CMakeLists.txt when I click on it )? Or I miss something?

I tried to run cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS as described here but it refuse with error message:

prokop@s2-041:~/git/SimpleSimulationEngine/cpp/Build$ cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS
Parse error in command line argument: -DCMAKE_EXPORT_COMPILE_COMMANDS
Should be: VAR:type=value
CMake Error: No cmake script provided.
CMake Error: Problem processing arguments. Aborting.

EDIT

OK, so according to the advice below I run

cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

and now it generate compile_commands.json but I still cannot open it with KDevelope ... the Import Project dialog still shows everything gray and inactive (see screenshots below). Not sure if it matters that I run KDevelop under xubuntu 18.04 LTS (not Kubuntu) and Gnome-Flashback Desktop environment.

enter image description here enter image description here enter image description here

Prokop Hapala
  • 2,424
  • 2
  • 30
  • 59

2 Answers2

1

This should still work in KDevelop 5. There's no need to run cmake -DCMAKE_EXPORT_COMPILE_COMMANDS .., KDevelop will do it for you.

The version of KDevelop packaged in Ubuntu 18.04 is rather old and has many known bugs, please try the 5.4.2 AppImage and see if that resolves your problem.

FLHerne
  • 267
  • 2
  • 5
  • 1
    OK, it works now. Maybe it worked also with default ubuntu KDevelop, but I tried to open file `CMakeList.txt` or `*.json` which does not work. In this ne version the dialog stated explicitly "Open Directory" which helped me. – Prokop Hapala Sep 04 '19 at 13:31
  • But still, I have a some inconvenience with KDevelop. I have project with multiple targets (hundrets, they are small 3D demos) and when I try to choose which one to run I always have to go to `Run > Configure Lunches` ... delete the previous one, and add the new one, apply, then build and run. That is too much work. In `Code::Blocks` which I used up to now I can just select build target from drop-down list by one click, and hit run. Is there some simple option like this in KDevelop? – Prokop Hapala Sep 04 '19 at 13:36
  • In `Configure Launches` you can create more than one launch option. Then switch between them with the `Run > Current Launch Configuration` menu. – FLHerne Sep 04 '19 at 13:43
  • I tried this `Build Sequence` box in lower left corner, and also right-click to build target in `projects` menu/treeview but it does not work. `Run > Configure Launches` and setting Build Dependencies works, but it is quite tedious. – Prokop Hapala Sep 04 '19 at 13:49
0

You should put the path to your source (top-level CMakeLists.txt file) at the end of your command, after any options.

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..

Here is the command line syntax documentation.


Edit: As Tsyvarev points out, CMake specifically complains about your -D syntax, which is missing the assignment to ON.

Kevin
  • 16,549
  • 8
  • 60
  • 74
  • 1
    Actually, CMake complains about missing **assignment** in the option setting. Since `CMAKE_EXPORT_COMPILE_COMMANDS` has a flag semantic, for set this flag on should pass `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` (or, with type set, `-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON`). As for order between source directory and other options, it is actually not so important, despite what is stated in the docs. – Tsyvarev Sep 03 '19 at 22:49