How to use Cmake in Codelite

General questions regarding the usage of CodeLite
Fox Mulder
CodeLite Enthusiast
Posts: 38
Joined: Wed Oct 03, 2012 12:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

How to use Cmake in Codelite

Post by Fox Mulder »

Hello,
I understand the benefits in using cmake instead of custom build system and I red the tutorials from cmake to create a cmakeLists.txt and use the gui app to generate project files for different IDEs.
However I don't understand how Cmake is integrated in Codelite. Actually I don't understand how to use it through Codelite.
I downloaded the Cmake RC3.0 and under PlugIns ->Cmake->Settings I set the path to the Cmake exe. In this dialog I can choose the generators but here is the first I don't understand: I thought I can choose here between all generators Cmake can handle, e.g. VS11, C::B, Eclipse..., instead there is just Mingw Makefile to choose.

Then I noticed the Tab Cmake help and reloaded the help files - Impressive help lib and absolute complete, However it would be nice if there would be a Start page with a small tut how to use Cmake through CodeLite.

Next I searched the option how to activate Cmake, actually I don't even know that it have to be activated because I still don't understand what Codelite would do with a activated Cmake.
Under Project ->Settings there is a tab "Cmake" where you can enable Cmake for this project. There are some other options to choose from like the source Path and the Target Path and again the option to choose the generator to override the global one.
So after I enabled it and Build the project I expected that a CmakeLists.txt would be generated and my build would be transferred to the Target path I set in the Settings dialog. Instead an empty Target directory was created, nothing else.
Then I noticed if I right click the project there is a option "Cmake" with the 3 options: "Open CmakeLists.txt" (disabled), "ExportCmakeLists.txt", and "MakeDirty"(also disabled)
I exported the cmakeLists.txt and a file in my directory was created with all the linker settings and the paths I set in the Build Settings.
I think I can use this file from Cmake Gui exe and generate my project for VS for example.
So how CodeLite integrates Cmake. Is it just to generate the CmakeLists file? If so, what are all the settings for? I expected this plugin can call cmake.exe and generate the Project with the generator I choose.
I hope someone would read my long post and can clear some things out for me.
Thanks.
I want to believe.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use Cmake in Codelite

Post by eranif »

There are 2 approaches:

1. Let CMake generate your project files (assuming you are using CMake 3.0)
So whenever you add file to the project you need to regenerate the project files using CMake (i.e. the project files will get overwritten each time you generate them)

2. (this is how I use CMake + CodeLite) Define your project as 'Custom Build' from the project settings -> Enable custom build
Add new targets from project settings->customize->custom build to run cmake, for example:

For example:
Select codelite's build configuration to 'Debug',
Then switch to the project settings->customize->custom build
Set the working directory to '$(WorkspacePath)/build-debug'
Add new target by clicking on the 'New' button

Code: Select all

Target name: cmake
Command: cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug
Edit the 'Build Target':
Double click it and type 'mingw-32make -j8' as the command

From this point, right clicking on the project and selecting 'custom build targets' will show 'cmake'
while hitting the normal build button will execute the build command

** Note that I assume here that you are using Windows

Some side notes:

Side note #1:

You assume that we intend to expose all CMake functionality, well that is not our intention
Think of it, what incentive do codelite developers have to support the generation of eclipse files ... ?
We generate what we can handle: MinGW, NMake and Unix Makefiles
The purpose of the plugin are:
1) Provide integrate cmake help inside codelite
2) Use an existing cmake files to perform the build (run cmake if needed)

Site node #2: codelite 6.0 includes CMake templates with CMakeLists.txt files ready to use

Eran
Make sure you have read the HOW TO POST thread
Fox Mulder
CodeLite Enthusiast
Posts: 38
Joined: Wed Oct 03, 2012 12:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use Cmake in Codelite

Post by Fox Mulder »

Think of it, what incentive do codelite developers have to support the generation of eclipse files ... ?
We generate what we can handle: MinGW, NMake and Unix Makefiles
Ok that makes sense. On the other hand I thought Cmake is exactly for that purpose. If someone asks me my project to share with, but he only uses Eclipse than I build my project from Codelite for Eclipse and send him the files (maybe I understand it wrong)
If I understand right, you use the default codelite Build System in debug mode and then if you are happy with the result you change the configuration to "CmakeConfiguration" and build again.
I will try to follow you description and see how far I get.
Thanks.
I want to believe.
Fox Mulder
CodeLite Enthusiast
Posts: 38
Joined: Wed Oct 03, 2012 12:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use Cmake in Codelite

Post by Fox Mulder »

Ok I have an error if go to build Targets Cmake.
Translated from german: mingw-32make command not found or wrong written.

Edit: Ok it should be mingw32-make instead mingw-32make.
What does -j8 means?
I want to believe.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use Cmake in Codelite

Post by eranif »

Fox Mulder wrote:What does -j8 means?
Depends on your machine, if your machine can run 8 threads at the same time, -j8 means: compile with 8 jobs at the same time
"j" is for "jobs" - how many parallel jobs to run

Eran
Make sure you have read the HOW TO POST thread
Fox Mulder
CodeLite Enthusiast
Posts: 38
Joined: Wed Oct 03, 2012 12:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use Cmake in Codelite

Post by Fox Mulder »

Can you check this line pls.
"cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug"( without quotes)
I typed it into the Comand line for the new Target Name "cmake"
I have the error: cmake command is wrong written or could not be found.
I want to believe.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use Cmake in Codelite

Post by eranif »

Seems OK to me
What happens when you run in from a terminal (CMD.EXE) ?

Eran
Make sure you have read the HOW TO POST thread
Fox Mulder
CodeLite Enthusiast
Posts: 38
Joined: Wed Oct 03, 2012 12:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use Cmake in Codelite

Post by Fox Mulder »

if I type the same line in CMD I get the same error- so I checked the path variable but it was ok, so I typed cmake into cmd and it works.
I think something is wrong with the line

Edit: There are quotes around Mingw... maybe they shouldn't be there I will test some things
I want to believe.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use Cmake in Codelite

Post by eranif »

You should print the log as it shown from codelite and use code tags.
Eran
Make sure you have read the HOW TO POST thread
Fox Mulder
CodeLite Enthusiast
Posts: 38
Joined: Wed Oct 03, 2012 12:19 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use Cmake in Codelite

Post by Fox Mulder »

I deleted the hole project and start from scratch cause Codelite crashed the 3 time now.
A quick question for understanding: What does Working Directory mean under ProSetting->Custemize? Should it be my Project Path or Workspace Path?
I want to believe.
Post Reply