Author Topic: CMake Generator Plugin  (Read 14524 times)

Offline Kazade

  • Multiple posting newcomer
  • *
  • Posts: 73
CMake Generator Plugin
« on: February 15, 2009, 09:12:41 pm »
I've written a little plugin which generates a CMake configuration file (CMakeLists.txt) file for the current workspace and the currently active target. At the moment it is very limited, it only works on Linux (I'll fix this asap) it does the following:

1. Prompts for an output directory for the file
2. Asks for a name for the CMake project ( a CMake "project" pretty much equates to a "workspace")
3. With this information the relative paths of the source files for each project are calculated and stored
4. Each project's include directories are read and if pkg-config or wx-config commands are in the list of compiler options they are called and the output parsed
5. Same thing happens with the libraries
6. Any compiler flags are read
7. Everything is written to the CMakeLists.txt file using ADD_EXECUTABLE or ADD_LIBRARY depending on the target type

I've tested the plugin on itself (to generate the file) and then successfully compiled the plugin outside of CodeBlocks using CMake (hehe, recursive ;) ) and my friend has tested it on his projects, it seems to work.

This is the TODO list:

1. Get it working on Windows
2. If any project names begin with "test" add them to cmake as unit tests
3. Somehow add some per-project options to specify per project custom commands (e.g. CMake module checks)
4. Add multiple build targets to the cmake output
5. Write a configuration dialog (options like required cmake version etc.)

The plugin can be downloaded from: http://www.kazade.co.uk/downloads/CMake_Generator.cbplugin . If people could just try it out on their current workspace to generate the file, then go to the output directory in a terminal and type "cmake . && make" and let me know if it works that would be cool (obviously, you need cmake installed).

I'll upload the source later... when it's a little less hacky :)

P.S.
I'm new to this plugin writing... and wxString. Can someone tell me, what is the best way to concatenate the content of two wxArrayString instances? At the moment I'm looping and adding the second to the first but this is a few lines of code.. I was hoping there was a way to do it in a single statement.
« Last Edit: February 15, 2009, 09:26:25 pm by Kazade »

Offline cmattb

  • Single posting newcomer
  • *
  • Posts: 4
Re: CMake Generator Plugin
« Reply #1 on: February 16, 2009, 09:17:02 am »
I've not tried your plugin, however wxString concatenation is fairly simple...

http://docs.wxwidgets.org/2.6/wx_wxstring.html#concatenationinwxstring

For example here is one way to do it:

wxString wxsHello = wxT("Hello");
wxString wxsWorld = wxT("World");

wxsHello  += wxT(" ") + wxsWorld;

Offline Kazade

  • Multiple posting newcomer
  • *
  • Posts: 73
Re: CMake Generator Plugin
« Reply #2 on: February 16, 2009, 11:17:26 am »
Thanks, but I knew how to concatenate wxString.. but not wxArrayString. Looking at the wxWidgets docs there seems to be a macro to do this (why a macro?!).

Offline cmattb

  • Single posting newcomer
  • *
  • Posts: 4
Re: CMake Generator Plugin
« Reply #3 on: February 16, 2009, 11:54:21 am »
Sorry, I completley misread your post  :(

I did think it strange that someone who had written a whole plugin had missed how to concatenate a string ;)

My only suggestion would be to use the join / split functions but I have no idea how efficient it is. It would seem to probably end up with some wasted heap management.

http://docs.wxwidgets.org/trunk/group__group__funcmacro__string.html

wxArrayString a1 = {...};
wxArrayString a2 = {...};
wxArrayString all;
wxString s1;
wxChar sep = '!'

s1 = wxJoin(a1,sep) + wxJoin(a2,sep)
all = wxSplit(s1,sep);

You've probably ruled this out already, so sorry if I'm wasting your time here....





dan77062

  • Guest
Re: CMake Generator Plugin
« Reply #4 on: February 27, 2009, 09:40:41 pm »
This is a great idea but the plug in did not work for me.  In fact, it crashed hard.
It did run, asking for a directory but once I specified the directory the GUI went gray and all of Code Blocks died, completely unresponsive.
I'm using Ubuntu intrepid, code blocks 8.02.

ghoti

  • Guest
Re: CMake Generator Plugin
« Reply #5 on: April 13, 2009, 08:06:24 am »
I got the same as above, c::b crashed and burned.

Any updates/work on this anymore?  It is a fantastic idea.

Thanks!

Offline dejan

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: CMake Generator Plugin
« Reply #6 on: April 19, 2009, 05:12:53 pm »
I need this plugin badly!

I tried to install it, but installation failed because plugin has been built for old SDK... Can you give us a source so i can try to build pluing for my (bleeding edge - SVN) version of Code::Blocks?