Hi! I'd like to propose an enhancement to the pkg-config .pc files. This enhancement will enable static linking using pkg-config information, and it will not affect dynamic linking.
For this purpose, the following changes are necessary: 1) The various openscenegraph-osg*.pc files need to provide the additional "Libs.private" field that lists library dependencies specifically for static linking. For example, on MinGW the file openscenegraph-osg.pc would contain "Libs.private: -lglu32 -lopengl32". Since the "Libs.private" field is only used when pkg-config is used with the --static option, dynamic linking will not be affected by this change. 2) The additional file openscenegraph-osgPlugins.pc is required, to allow explicit static linking of the plugins. This file would list the base OSG libraries in the "Requires" field, and all plugins along with all their external dependencies in the "Libs.private" field. The "Libs" field remains empty, so that dynamic linking is not affected (of course, an application using dynamic linking does not need to use openscenegraph-osgPlugins.pc at all, but it could choose to do so for consistency). This approach is currently used by mingw-cross-env <http://www.nongnu.org/mingw-cross-env/>, a MinGW cross-compiling environment that provides only static libraries and deliberately avoids DLLs. It allows to compile the osgstaticviewer example with this command: i686-pc-mingw32-g++ -DOSG_LIBRARY_STATIC \ -o osgstaticviewer.exe examples/osgstaticviewer/osgstaticviewer.cpp \ `i686-pc-mingw32-pkg-config --cflags openscenegraph-osgViewer openscenegraph-osgPlugins` \ `i686-pc-mingw32-pkg-config --static --libs openscenegraph-osgViewer openscenegraph-osgPlugins` All the information that is required for 1) and 2) is available from CMAKE; it is explicitly listed in CMakeCache.txt in the "Dependencies for the target" sections. It should be possible to export it from CMAKE into the .pc files. Unfortunately, I did not find a way to do this (mingw-cross-env currently hard codes this information). Is there a CMAKE expert that can help with this? Would this change have a chance of being accepted? Martin _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
