How to Create a basic fltk/fluid project using kdevelop

After asking "Anyone using kdevelop with fltk and fluid" in fltk.general
(see http://www.fltk.org/newsgroups.php?gfltk.general+v:26001) I wanted
to try it out for myself anyway. I was interested in kdevelop because:

  + it offers support for autoconf and automake
  + it offers support for building distribution tarballs
  + it offers support for doxygen
  + I thought the class manager would simplify code refactoring

I used kdevelop-3.5.2 for this investigation, with fltk-1.1.9. However,
my desktop environment is Xfce, so I probably didn't have all of the
low-level kde3 components installed or configured. What I found was:

  + without low-level kde3 stuff, it was difficult to remove files
  + rebuilding didn't always work first time after changing files
  + fluid must be run by hand, but kdevelop will rebuild the files
  + kdevelop hides the top-level configure.ac functionality so you
    would need for a standalone autoconf environment
  + there is no automated support for code refactoring


If anyone else wants to try it out, here are the steps I followed:

In kdevelop:
  + Project / New Project / All Projects Tab
    - select C++ / Simple Hello World Program
    - set application name [foo] and directory, hit Next
    - set author and email strings, hit Next
    - say No to version control, hit Next
    - accept .h header comment, hit Next
    - accept .cpp header comment, hit Finish
  + Project / Project Options / Configure Options
    - set CPPFLAGS to `fltk-config --cxxflags`
    - set LDFLAGS  to `fltk-config --ldstaticflags`
    - hit OK and Don't Run Configure Now
  + Add the following doxygen comment to foo.cpp
      /** \mainpage Foo Project Documentation
       *
       * Welcome to the Foo Project. etc...
       */

Run 'fluid ui.fl' in the foo/src directory:
  + New / Code / function/method
    - make_window() / blank / hit OK
  + New / Group / Window
    - add label and resize window as appropriate
  + File / Save
  + File / Quit

In kdevelop:
  + Automake Manager (in vertical menu on right hand side)
    - right-click on 'foo (Program in bin)'
    - Add Existing files, add ui.fl, hit OK
  + change/add the folowing lines to the top of src/Makefile.am:
      bin_PROGRAMS = foo
      foo_SOURCES = foo.cpp ui.fl
      nodist_foo_SOURCES = ui.h ui.cxx

      SUFFIXES: .cxx .fl
      .fl.h:
      <tab>fluid -c $<

      BUILT_SOURCES = ui.h
      CLEANFILES = ui.h ui.cxx
  + change/add the following lines in foo.cpp:
      #include "ui.h"

      int main(int argc, char* argv[])
      {
        Fl_Double_Window* win = make_window();
        win->show(argc, argv);
        return Fl::run();
      }

In kdevelop:
  + File / Save All
  + Build / Run Automake & friends
  + Build / Run Configure
  + Build / Build Project
  + Build / Build API Documentation


The hardest part was getting the src/Makefile.am rules right so allow
fluid to build ui.h and ui.cxx. I have a variation on this theme where
foo_SOURCES contains ui.cxx and not ui.fl, and the SUFFIXES line does
not appear. An autoconf/make expert might be able to improve on this.

What I have done is to demonstrate proof-of-concept.  I have verified
that foo compiles and runs, and the main documentation page builds as
expected. I have not experimented with alternate build directories,
nor creating a user interface library sub-project. I leave all this,
and more, as an exercise for interested readers.

I "attach" the relevant files below (minus any header comments).

Enjoy!


src/Makefile.am:

    bin_PROGRAMS = foo
    foo_SOURCES = foo.cpp ui.fl
    nodist_foo_SOURCES = ui.h ui.cxx

    SUFFIXES: .cxx .fl
    .fl.h:
        fluid -c $<

    BUILT_SOURCES = ui.h
    CLEANFILES = ui.h ui.cxx

    # set the include path found by configure
    INCLUDES= $(all_includes)

    # the library search path.
    foo_LDFLAGS = $(all_libraries) 


src/foo.cpp:

    #ifdef HAVE_CONFIG_H
    #include <config.h>
    #endif

    #include "ui.h"

    /** \mainpage Foo Project Documentation
     *
     * Welcome to the Foo project
     */

    int main(int argc, char *argv[])
    {
        Fl_Double_Window* mainWin = make_window();
        mainWin->show(argc, argv);
        return Fl::run();
    }


src/ui.fl:

    # data file for the Fltk User Interface Designer (fluid)
    version 1.0109 
    header_name {.h} 
    code_name {.cxx}
    Function {make_window()} {open
    } {
      Fl_Window {} {open selected
        xywh {590 469 100 100} type Double visible
      } {}
    } 

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to