Dienstag, 31. Januar 2017

Configure CodeLite to develop C++14 applications with CMake and CLang

First configure CodeLite so that it uses CLang for code completion: Settings -> Code Completion... -> Clang. Enable both Enable clang code completion and Only use clang code completion.

The structure of the project will be:
<project dir>
  |- Debug
  |- src
  |- Release

Create first a new workspace and then open the Workspace Settings....


On the Code Completion tab select Enable C++14 Standard.

Create a new project inside this workspace (File -> New -> New Project) and select Others -> Custom makefile as project type. Then select a project name and the <project dir> for the project path. Select the clang compiler, LLDB Debugger and CMake in the next step and finish the project wizard.

Select Import Files From Directory to import your source files.



Open the project settings and adjust the following settings:
General:


  • Intermediate Folder: $(ProjectPath)/$(ConfigurationName)
  • Output File: Name of your executable
  • Executable to Run / Debug: $(ProjectPath)/$(ConfigurationName)/$(OutputFile)
Custom Build:



  • Working Directory: $(ProjectPath)/$(ConfigurationName)
  • CMake: mkdir -p $(ProjectPath)/$(ConfigurationName) && cd $(ProjectPath)/$(ConfigurationName)  && cmake ../src -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_BUILD_TYPE=Debug
Repeat the steps also for the Release configuration and change -DCMAKE_BUILD_TYPE=Debug to -DCMAKE_BUILD_TYPE=Release.

Then execute your custom CMake command:
 

and the build your project.

Now the code completion should work.

A list of variables supported by CodeLite can be found in the following source file: macrosdlg.cpp