[CMake] Searching for an undefined symbol in library

Marek Szuba marecki at gmail.com
Mon Nov 15 10:40:31 EST 2010


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,
-- 
MS


More information about the CMake mailing list