wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
5.75k stars 1.69k forks source link

wx-config: Allows wx apps using a /contrib library to build #5947

Closed wxtrac closed 2 years ago

wxtrac commented 20 years ago

Issue migrated from trac ticket # 5947

priority: normal

2003-06-08 08:02:28: robertoconnor created the issue


Currently, there is not a suitable way to create a posix Makefile for a wxWindows app, if that wxWindows app using one of the /contrib libraries, such as the XRC library or the StyledTextCtrl library.

The reason is that the person writing the app makefile doesn't know how the next builder will build his wxWindows libraries (debug or non-debug; unicode or not; what release, etc), Each of these features change the filename of the built contrib library that the app needs to link to.

While there are very long, roundabout ways of getting the name of the /contrib library using sed scripts and others, everyone is going to be in the same boat and hit this same roadblock, so it is easier to have it just as a quick item in wx-config, which already has all of these things for calculating the basename of the library.

With these short entries in wx-config, a wxWindows app can just do a make, make install and not worry about what type of options the wxWindows library was built with. This patch adds a --basename option which returns the basename of the library, and a --release which returns the release of the library. These then can be used for generating the /contrib library name. For example, here is the relevant snippet of the makefile:

---------------------------

TARGET = plucker-desktop

CXXFLAGS = -g -O2 wx-config --cflags

WX_LIBRARY_BASENAME = wx-config --basename WX_RELEASE = wx-config --release

Use with/without the stc depending on whether want to

use styled text control ('stc') LDLIBS = wx-config --libs -l$(WX_LIBRARY_BASENAME)_xrc-$(WX_RELEASE) -l$(WX_LIBRARY_BASENAME)_stc-$(WX_RELEASE)

CXX = g++ $(CXXFLAGS)

Include the list of .cpp files of the project as a

SOURCES variable. SOURCES = plucker-desktop.cpp \ mysecondfile.cpp

Build a list of objects, based on the list of sources

OBJECTS = ${SOURCES:.cpp=.o}

all: $(TARGET)

$(TARGET): $(OBJECTS) $(CXX) -o $@ $(OBJECTS) $(LDLIBS)

-------------------------

The wx-config --release is also needed if one wants to get the filename of the .rsrc file on OSX, so that it can be moved into an OSX bundle, when using ones one makefiles for building an OS X bundle without the wxWindows entries in the bundle (to include a proper icon, a full property list, etc).

For example, the Makefile snippet for the rsrc part of the OSX bundle would be:

-------------------------

wxwindows_lib_dir = $(shell wx-config --prefix)/lib WX_LIBRARY_BASENAME = wx-config --basename WX_RELEASE = wx-config --release

TARGET = plucker-desktop BUNDLE = Plucker.app/Contents

...copy the rest of the files into the bundle (which

is just an directory with a suffix of ".app"), like copying the executable, your icns icons file, runtime resources, etc

....then copy the .rsrc file into the bundle:

-cp $(wxwindows_lib_dir)/lib$(WX_LIBRARY_BASENAME)-$(WX_RELEASE).rsrc $(BUNDLE)/Resources/$(TARGET).rsrc

-----------------------------

wxtrac commented 20 years ago

2003-06-08 08:02:28: robertoconnor uploaded file basename_release_wxconfig.patch (1.1 KiB)

Patch for wx-config for apps to use /contrib libs

wxtrac commented 20 years ago

2003-06-08 08:09:29: robertoconnor commented


Here is the full wx-config.in file, also, in addition to the patch.

Look at the --basename and --release entries in the file.

2003-06-08 08:09:29: robertoconnor uploaded file wx-config.in (5.2 KiB)

The full wx-config.in file, for easier reading

wxtrac commented 20 years ago

2003-06-09 10:31:48: @vslavik commented


Yes, we will certainly need something like that. I would also like to propose something more: a --libs argument to wx-config that would use basename and release to produce libraries name. E.g. wx-config --libs=xrc,stc would produce -lwx_gtkd_xrc-.2.5 -lwx_gtkd_stc-2.5

wxtrac commented 20 years ago

2003-06-10 04:53:52: robertoconnor commented


Hi Vaclav,

Sounds great. That is a very good point, would be nice to make it even simpler yet for the contrib libraries.

There is a current wx-config --libs, which on OSX returns (and on GTK produces something vaguely similar):

-L/usr/local/lib -framework Carbon -framework System
/usr/local/lib/libwx_macd-2.4.a -lz -lpthread

Do you prefer to extend the --libs with optional arguments, so that wx-config --libs=xrc,stc would return this:

-L/usr/local/lib -framework Carbon -framework System
/usr/local/lib/libwx_macd-2.4.a -lz -lpthread -lwx_macd_xrc-.2.5 -lwx_macd_stc-2.5

Or would you prefer a wx-config --contrib-libs=xrc,stc which would just return this: -lwx_macd_xrc-.2.5 -lwx_macd_stc-2.5

Or other?

Best wishes, Robert

wxtrac commented 20 years ago

2003-06-11 16:58:48: @vslavik commented


I think the best would be to extend --libs to behave as it does now and accept optional =LIBS part. --contrib-libs approach is OK as well, I would only choose a different name that doesn't contain "contrib". (The reason is that we will switch to new build system and split the library into smaller parts soon, so it will make sense to e.g. say --libs=base,gui to not use wxHTML component...)

wxtrac commented 20 years ago

2003-06-18 05:18:11: robertoconnor commented


Hi Vaclav,

Sounds good.

Can this patch be applied then, so that basename and revision support is available? (since we need it for OSX resource linking anyways).

Then when we have the new build system, we can put some suitable changes to wx-config.in so that we can also use the --libs=xrc,stc format for direct linking.

Best wishes, Robert

wxtrac commented 20 years ago

2003-07-30 00:54:32: @vslavik commented


I just checked in new wx-config that supports --libs=xrc,stc syntax.