11

I have switched from Eclipse and Code::Blocks and would like to know how to set a project in Kdevelop to c++11 mode (std=c++11)

jproton
  • 766
  • 1
  • 7
  • 15

1 Answers1

13

I'll post this as an answer because the comment got too big.

KDevelop uses external build systems for its projects, so you can always find and edit make/cmake/whatevermake to add -std=c++11 to the compile commands. It doesn't have anything internally or options to set it, at least for CMake based stuff AFAIK. I had to add SET(CMAKE_CXX_FLAGS "-std=c++1y") to CMakeLists.txt, however I am not sure if this satisfies you.

Perhaps as you have indicated, the best practice is to append the command to the current flags at some point of CMakeLists.txt: SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11").

Alternatively, you can do essentially the same from the KDevelop menus. When you go Project -> Open Configuration, in the left panel you should have CMake and Make.

For CMake you can click Show Advanced, then check Show Advanced Values, then a listing of cached values for the project configuration shows up. You can find CMAKE_CXX_FLAGS there and add -std=c++1y to there.

I don't work enough with make utilities to know if this can be done with the options given there.

I also don't think there is anything smarter in KDevelop that would allow it to be more portable e.g. between different compilers.

The option:

Option

The dialog:

Dialog

luk32
  • 15,812
  • 38
  • 62
  • I have kdevelop 4.6 but there is no open configuration submenu in Project. – jproton Jun 26 '14 at 15:59
  • As a side note for anyone reading, there's this alternative : SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") – jproton Jun 26 '14 at 19:48
  • 1
    I have `4.6.60` and I have this option. I added the pictures. And of course, how you set `CMAKE_CXX_FLAGS` to add this option is up to you. I showed how to set the flags, you append the `-std=c++11`. Maybe I should have made it more detailed, but it was just an example. I included this suggestion. – luk32 Jun 27 '14 at 11:21
  • Oh yes right , there is open configuration but it looks disabled i ignore why – jproton Jun 27 '14 at 15:30
  • 1
    You have to have a project chosen in the Projects panel. By default this panel is located left of the code. There are also 4 tabs or so, Filesystem, Projects, Classes, and Documents. It's hidden beneath the menu on the screen shot. – luk32 Jun 27 '14 at 17:46
  • 1
    If i could upvote you eveb more would have done. I hope future users will benefit from this well documented issue. – jproton Jun 28 '14 at 15:02
  • I dont have CMAKE_CXX_FLAGS, what do i do? – Pavel Sep 16 '16 at 05:04