Page 1 of 2

How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 2:32 pm
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.

Re: How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 2:54 pm
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

Re: How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 3:08 pm
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.

Re: How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 3:54 pm
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?

Re: How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 4:01 pm
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

Re: How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 4:22 pm
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.

Re: How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 4:37 pm
by eranif
Seems OK to me
What happens when you run in from a terminal (CMD.EXE) ?

Eran

Re: How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 4:53 pm
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

Re: How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 4:56 pm
by eranif
You should print the log as it shown from codelite and use code tags.
Eran

Re: How to use Cmake in Codelite

Posted: Fri Apr 18, 2014 5:07 pm
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?