[CMake] FindwxWidgets and wxpng

Miguel A. Figueroa-Villanueva miguelf at ieee.org
Fri Dec 7 07:35:07 EST 2007


On Dec 6, 2007 8:01 PM, James Bigler wrote:
> Miguel A. Figueroa-Villanueva wrote:
> > On Dec 6, 2007 6:05 PM, James Bigler  wrote:
> >> James Bigler wrote:
> >>> In windows it looks for the library path by looking for the wxpng library:
> >>>
> >>>       FIND_PATH(wxWidgets_LIB_DIR
> >>>         NAMES wxpng.lib wxpngd.lib
> >>>         PATHS
> >>>         ${WX_ROOT_DIR}/lib/vc_lib   # prefer static
> >>>         ${WX_ROOT_DIR}/lib/vc_dll
> >>>         DOC "Path to wxWidgets libraries?"
> >>>         NO_DEFAULT_PATH
> >>>         )
> >>>
> >>> There's nothing in the documentation that states I have to have compiled
> >>> wxpng for this to work.  It seems like it should be using at least one
> >>> of the libraries that I asked it to look for (which didn't include
> >>> wxpng), such as base or core or mono.
> >>>
> >>> I'm using cmake 2.4.7 on win XP with wxWidgets 2.8.7.
> >
> > Is the wxpng.lib an optional package? If so, I'll change it...
>
> I certainly don't link against it to open simple applications.
>
> > I had thought about using this, since both monolithic and multilib
> > versions would have it... What is the best thing to probe for then?
> > Probably I should put in the base and mono NAMES so that it can figure
> > it out everytime.
>
> That seems like a good idea.

I remember now why I used the wxpng.lib for finding the libs. The base
and mono libs carry the version number with them (e.g., wxbase28.lib).
So, if I use that then it's a maintainance issue and the module would
stop working for each new release of wxWidgets.

If you set wxUSE_LIBPNG to 0 in setup.h, will it not get created? or
is this just to set things up when not linking to it?

> >> In addition, it looks like I have to have these libraries:
> >>
> >>    #useful common wx libs needed by almost all components
> >>     SET(wxWidgets_COMMON_LIBRARIES  png tiff jpeg zlib regex expat)
> >>
> >> So, if I didn't ask for them, whey are they required?
> >>
> >>          # Always add the common required libs.
> >>          LIST(APPEND wxWidgets_USE_LIBS ${wxWidgets_COMMON_LIBRARIES} )
> >>
> >> The unix version doesn't require these libraries, so why does the
> >> windows one require them?
> >
> > The unix version uses wx-config. It is much easier to do things
> > through wx-config, because wx-config knows how wxWidgets was
> > configured. However, the windows version is not so fortunate... I find
> > it has a terrible distribution system. As I have said before,
> > wxWidgets should use CMake for their build system manager ;)
> >
> > That said, what is being done is that if it is built we add it to
> > wxWidgets_LIBRARIES if not.. it will not fail to find wxWidgets. We
> > could provide some sort of wxWidgets_NO_LINK_COMMON_LIBS or
> > something... is this really necessary?
>
> I don't know the common libraries were "required" libraries (they
> probably are).  I guess these libraries are required or not depending on
> how you configured wxWidgets from setup.h.
>
> I guess a good question for the wxWidgets mailing list would be to know
> if you really need those libraries or not.  If it's dependent on the
> value in the macro, then it might be feasible to pull the information
> from setup.h by either parsing the file directly, or by a TRY_COMPILE
> with a tailored executable that could spit out information on which
> features are available.
>
> That's a little extreme, though.  I good middle ground would be simply
> telling the user which required wx libraries weren't found.

I think the correct approach would be to add a dependency graph, so
that if I ask for libs that don't depend on these common libs they
won't get linked in. Also, we would need to determine what optional
things are controlled by the setup.h.

Note, however, that wx-config in unix style doesn't do dependency
scanning and it would probably hurt cross-platform use of the find
module. So, I rather delegate this to the user to specify the correct
libs to use including the dependency.

The only issue is whether I want to have users need to specify the
common libs in the majority of cases:

FIND_PACKAGE(wxWidgets COMPONENTS base core png tiff jpeg zlib regex expat)

in order to allow very few people to do the following without linking
in the rest:

FIND_PACKAGE(wxWidgets COMPONENTS base core regex expat)

I think a compromise would be to have a wxWidgets_NO_COMMON_LIBS as
mentioned before and then if you don't want to link all the others do:

SET(wxWidgets_NO_COMMON_LIBS TRUE)
FIND_PACKAGE(wxWidgets COMPONENTS base core regex expat)

To be able to do this I need the full dependency graph to analyze the
best course of action. I don't have the time to search and test for
this, but if you are interested you can fill in the blanks and I'll
take action to implement this. There is a partial dependency graph
here:

http://www.wxwidgets.org/manuals/stable/wx_librarieslist.html#librarieslist

--Miguel


More information about the CMake mailing list