Page 1 of 1

Using CMake with CodeLite

Posted: Sun Nov 22, 2009 12:36 am
by Mad Fish
How to do it right way?

Creating a project with a custom makefile just leaves many things not working - compilation errors doesn't show, code completion doesn't work for included files not in default path (their pathes are found by cmake during the confiugration).

Really, why reinvent the wheel, when CMake exists? It's so flexible, and can be used with any IDE (theoretically).
It would be so great to have a native CMake support, out of the box.

Re: Using CMake with CodeLite

Posted: Sun Nov 22, 2009 12:59 am
by eranif
Mad Fish wrote:Creating a project with a custom makefile just leaves many things not working
You probably forgot to tell codelite how to build. Custom makefile means that YOU provide the makefile
Mad Fish wrote:code completion doesn't work for included files not in default path
Not related. code completion has NOTHING to do with the way the project is setup. the CodeCompletion paths are different than the compiler ones (for various reasons which I will not list here) - to set up code completion include paths, you set them from the menu: 'Settings -> Tags Settings -> Include Files'
Mad Fish wrote:Really, why reinvent the wheel, when CMake exists?
Also, qmake, premake, configure and the list goes on and on...

Custom build does not re-invent anything. If you want to use CMake, use it - set the command to run for generating the makefile (you have a text field for it), and then specify the commands for the build (usually make for build and make clean for clean) - if you need help configuring it, ask here.
Mad Fish wrote:It would be so great to have a native CMake support, out of the box.
You can set up a project properly once, and then save it as template

I can imagine why you want to use CMake - cause you are probably familar with it. IMO, if you dont need to, use codelite internal managed makefile rather than using CMake. I will choose to use 3rd party makefile generator tools (like qmake) in cases when I am working on an already running project which uses it, if I can avoid it and let codelite manage my makefiles - I will prefer to let codelite to do it.

Eran

Re: Using CMake with CodeLite

Posted: Sun Nov 22, 2009 1:14 am
by Mad Fish
eranif wrote:You probably forgot to tell codelite how to build. Custom makefile means that YOU provide the makefile
It CAN build, but doesn't parse compilation errors.
eranif wrote:Not related. code completion has NOTHING to do with the way the project is setup. the CodeCompletion paths are different than the compiler ones (for various reasons which I will not list here) - to set up code completion include paths, you set them from the menu: 'Settings -> Tags Settings -> Include Files'
Why there are only global paths for code completion? Why there is no project-specific ones?
eranif wrote:Custom build does not re-invent anything. If you want to use CMake, use it - set the command to run for generating the makefile (you have a text field for it), and then specify the commands for the build (usually make for build and make clean for clean) - if you need help configuring it, ask here.
I set the command for generating, but it seems CodeLite doesn't execute it on build - at least, no cmake output is visible in "Output"
eranif wrote:I can imagine why you want to use CMake - cause you are probably familar with it. IMO, if you dont need to, use codelite internal managed makefile rather than using CMake. I will choose to use 3rd party makefile generator tools (like qmake) in cases when I am working on an already running project which uses it, if I can avoid it and let codelite manage my makefiles - I will prefer to let codelite to do it.
I want to use CMake because of automated dependency search. I just write find_package(...) and it's ready to use. It's so convenient. And also it allows to work in heterogeneous environment. For example, one developer is using Visual Studio, other one uses Eclipse, and the other uses CodeLite (or Code::Blocks, emacs, NetBeans, and so on).

Re: Using CMake with CodeLite

Posted: Sun Nov 22, 2009 8:37 am
by eranif
Lets start from start:

I will describe here, how to use qmake since I am most familiar with tool, you simply do s/qmake/cmake/ in the relevant placed

Assuming that I want to build my project with qmake generated makefiles, I will use qmake capability for generating gnu makefiles.
Now, what I want to achieve is the ability to run qmake (usually once) and then make.

To do this, I create a custom makefile project and then I do the following:
- right click the project and selects the 'custom build' tab (make sure it is enabled)
- in the 'makefile generators' I choose: Other
- in the 'Command to use for makefile generation' I place 'qmake'
- in the 'Working directory' I use the macro $(ProjectPath) (to see list of macros, click the 'Help...' button)
- I click OK and closes this dialog

See below the picture for how the dialog looks like.
qmake-project.PNG
Next, to build I first want to run qmake once to generate the makefile.
- right click the project and select 'Run Other' (I know, a better name could have been choosen here :P) - the output of CMake is placed in the 'Output' Tab
- From this point on - I simply use the common build shortcuts to build (F7) - the output of the build is set to the 'Build' tab.
menu.png
In case your generated makefile is using VC++ compiler (CL.EXE), make sure you selects the appropriate compiler so the output is parsed correctly - this is done in the project settings -> General Tab 'Compiler' choice control.

Hope this helps,

Re: Using CMake with CodeLite

Posted: Sun Nov 22, 2009 3:57 pm
by Mad Fish
Well, when .workspace and .project are in the same directory as the root Makefile, error parsing is working. Otherwise - no.

And some other minor issues:
* In the project settings there is no "All configurations" option, like in Visual Studio
* In workspace view, I can't see location of files. It would be more convenient for CMake project just to use Explorer tab. It would be great to have a option to set a root path for Explorer, so unrelated files will not appear.
* For the small screen (I'm working from netbook right now, 1024x600) icons in toolbar are VERY big. And the option to make them smaller doesn't make smaller the toolbar itself, so it's really useless. And I can't change toolbar size by hand.

And really, why, why the codecompletion paths are different from compiler ones? :cry:

Anyway, thanks for great IDE. It is the closest to ideal at moment (from all Linux C/C++ IDEs).

Re: Using CMake with CodeLite

Posted: Sun Nov 22, 2009 4:05 pm
by jfouche
Mad Fish wrote:* In the project settings there is no "All configurations" option, like in Visual Studio
There a 'global settings' choice in project settings which allow you to define options for all configurations. Maybe it would have been better to call it 'All configurations'.
Mad Fish wrote:* In workspace view, I can't see location of files.
If you import a directory, CL will create 'virtual directories', just like the filesystem one. You can create those virtual directory by hand, and add the file you want inside them.
Mad Fish wrote:And really, why, why the codecompletion paths are different from compiler ones?
You can define the path needed for code completion as you want in settings -> tag settings which allow you to add more available completion than just the compiler one.

Re: Using CMake with CodeLite

Posted: Sun Nov 22, 2009 5:14 pm
by eranif
Mad Fish wrote:* For the small screen (I'm working from netbook right now, 1024x600) icons in toolbar are VERY big. And the option to make them smaller doesn't make smaller the toolbar itself, so it's really useless. And I can't change toolbar size by hand.
Its a known bug with a simple solution:
- change the toolbar size to 16x16
- close codelite
- delete the file C:\Program Files\Codelite\config\codelite.layout
- restart codelite

Searching 'toolbar icons' in the forum gave me this:
http://codelite.org/forum/viewtopic.php ... cons#p2821

Eran

Re: Using CMake with CodeLite

Posted: Mon Nov 23, 2009 1:44 am
by Mad Fish
Just have noticed this:
http://www.cmake.org/Bug/view.php?id=9901

Really waiting for positive results there. Better integration will be great.