[CMake] how to select static libraries for linking?

Mike Jackson mike.jackson at bluequartz.net
Thu Jun 11 21:33:34 EDT 2009


On Thu, Jun 11, 2009 at 8:46 PM, James C.
Sutherland<James.Sutherland at utah.edu> wrote:
>>
>>  If you distribute on OS X then there are some CMake facilities to
>> help you create a stand alone .app bundle. Basically it will run
>> "install_name_tool" on the dylibs to make sure they reference
>> dependent libraries that are stored inside the .app bundle. Usually
>> this is a real pain to do by hand due to the dependency tree for each
>> library that needs to be taken into account.
>>
>> here is an example that does just that using the Qt libraries as an
>> example:
>>
>> http://www.bluequartz.net/software/files/QtTest.zip
>>
>>
>> On windows I would build with static libraries if at all possible.
>>
>> Mike
>>
>
> I was really hoping that CPack would do the heavy lifting for me.  Is that
> not the case?
>
> I looked at the example you provided, but I am not really enough of a CMake
> wizard to figure out what to change for my case...
>
> James
>

Well you need to follow the "OS X" path through the cmake files.
Basically a shell script and another cmake file are going to be
created. The shell script does a few things then calls cmake directly
with the generated cmake file as input. Inside that cmake file will be
all the code the "fixes up" the OS X bundle by adjusting all the
non-system libraries that your application links to.

You can use the "otool" command line program to find all the
dependencies that a library has:

572:[mjackson at Shepard:hdf5-169]$ otool -L hdf5/lib/libhdf5.dylib
hdf5/lib/libhdf5.dylib:
	/Users/mjackson/Desktop/hdf5-169/hdf5/lib/libhdf5.0.dylib
(compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 111.1.4)
	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)


What specifically do you need help with and maybe I can help you
change the file to suit your needs.

Mike


More information about the CMake mailing list