Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable c++11 in Kdevelop

Tags:

c++

kdevelop

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)

like image 796
jproton Avatar asked Jun 26 '14 15:06

jproton


1 Answers

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

like image 157
luk32 Avatar answered Sep 28 '22 03:09

luk32