4

I recently moved from developing with code::blocks to developing with kdevelop. (I got fed up of codeblocks being unstable and not being able to set keyboard shortcuts.)

As I understand it kdevelop uses cmake to control the building of source files... Not really sure why, but okay that's what was decided, so I'll live with it.

I don't really know anything about cmake. I guess it is like make?

What I really want to know is how do I set cmake to use g++ with the flag std=c++11.

According to this stackoverflow question, I should be able to use list(APPEND CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - but I think this might work only for make and not cmake...?

Anyone know how to set compiler options in kdevelop? Also could anyone explain why cmake is used, rather than most other IDE's which I have encountered before. I'm guessing there is a good reason for it.

Community
  • 1
  • 1
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225

1 Answers1

1

Well I just switched from KDevelop to QT Creator; I prefer the latter because it's a lot faster, more stable, and has very good tools for code and GUI design. QT Creator opens a wide variety of projects, including CMake, qmake, the latest QT tech, GIT and SVN repositories. It's also well integrated with valgrind, which is not a KDevelop feature.

Here are some CMakeLists.txt variables I use in my projects, they work in both IDEs:

set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type")
set(CMAKE_CXX_FLAGS "--pedantic-errors -Wall -Wextra -Werror -ftabstop=4 -march=native -std=gnu++11 -fshow-column -ftabstop=4 -frounding-math -pipe ${FABIO_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb3 -DDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(FABIO_CXX_FLAGS "-Wall -Wextra -Werror -DFABIO_THREADS=2" CACHE STRING "C++ flags for the current directory")
Fabio A. Correa
  • 1,968
  • 1
  • 17
  • 26
  • 2
    Hmm... QT Creator? How do you put up with the alien interface/ look and feel of the IDE? Anyhow, the c++11 problem has gone away, but I now get errors for using argc and argv without actually using them in my main function. Which compiler flag is causing this? I thought it was `-Werror` but I must be wrong. – FreelanceConsultant Aug 22 '13 at 19:56
  • 1
    pedantic and Wextra; you should enable them one by one and read the gcc documentation to see what is it that you really need. Yes, QT creator looks weird but the aspect (and keyboard shortcuts) are something one gets accustomed to; it always happens with a new IDE. – Fabio A. Correa Aug 22 '13 at 20:15
  • Yes that's true of course all IDE's are different in some respects... KDevelop has an "interesting" menu layout in that File isn't the first menu... Hmm, I just don't like the non-native looking interface. Perhaps I should be less picky about it. Can keyboard shortcuts be changed in QT Creator? – FreelanceConsultant Aug 23 '13 at 16:02
  • Yes you can change the shortcuts. – Fabio A. Correa Aug 23 '13 at 16:36
  • set(CMAKE_CXX_FLAGS -- this is what helped me. I added set(CMAKE_CXX_FLAGS "-lcurl") to get curl to compile and link with my program, rather than compiling from the command line. I like just having to click one button to build and debug. Thank you so much! – adprocas Feb 11 '16 at 13:14