Using CMake and C++11 With Eclipse

Adam posted @ Sun, 02 Mar 2014 17:09:07 +0800 in C++ with tags cmake c++ eclipse , 4890 readers

Eclipse is a Good IDE for C++.

And, CMake is a useful Makefile generation tool.

We hope that we might integrate them together.

1 Quick Start with Old Projects

mkdir buildeclipse
cd buildeclipse/
cmake ../SOURCE_FILES/ -G"Eclipse CDT4 - Unix Makefiles"\
    -DCMAKE_ECLIPSE_VERSION=4.3\
    -DCMAKE_CXX_COMPILER_ARG1=-std=c++11

Note:

If you get an error of like this:

Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.

use -D_ECLIPSE_VERSION=4.3 instead of -DCMAKE_ECLIPSE_VERSION=4.3.

2 A Project Example

PROJECT(HELLO)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# Optional
# or SET(_ECLIPSE_VERSION 4.3). If you add these, you may omit `-DCMAKE_ECLIPSE_VERSION=4.3`
SET(CMAKE_ECLIPSE_VERSION 4.3)

ADD_EXECUTABLE(main main.cpp)
TARGET_LINK_LIBRARIES(main pthread)

Refs:

CDT/User/FAQ

CMake:Eclipse UNIX Tutorial

stackoverflow


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter