[CMake] Searching for an undefined symbol in library

Michael Wild themiwi at gmail.com
Mon Nov 15 11:16:13 EST 2010


On 11/15/2010 04:40 PM, Marek Szuba wrote:
> Hello,
> 
> To begin with, a bit of background. The project which I've been
> converting to CMake depends on a certain binary-only library. This
> library is available in several versions, differing in what Fortran
> compiler has been used to produce it; to make things simple let's
> assume there are only two such variants, one for g77 and one for PGI
> Fortran. The latter version is not explicitly linked against PGI
> run-time libraries, making it necessary to include these libraries in
> my project's build scripts.
> 
> The problem at hand is that I would like my build scripts to
> automatically recognise the variant of the binary-only library. So
> far, i.e. in hand-crafted makefiles, this has been done by looking for
> PGI Fortan-specific symbols with nm, like this:
> 
> 	need_pgf = $(strip $(shell nm libX.so | grep ftn_i_sign))
> 	ifneq ($(need_pgf),)
> 		LIBS  += -L$(PGI)/lib -lpgc -lpgftnrtl
> 	endif
> 
> What do you think would be the best way of implementing something to
> similar effect in CMake, guys? Unfortunately the most simple option of
> checking for the presence of PGI-Fortran libraries does not work, as it
> can result in adding those libraries to a build that doesn't actually
> need them.
> 
> Thanks in advance for your comments. If you need any more information,
> please let me know.
> 
> Regards,

How do you select which of the libraries to use? Based on your Fortran
compiler? If so, I would check for the CMAKE_Fortran_COMPILER_ID
variable and then go on from there.

HTH

Michael


More information about the CMake mailing list