Re: [CMake] Searching for an undefined symbol in library

2010-11-16 Thread Michael Wild
On 11/15/2010 06:41 PM, Marek Szuba wrote:
> On Mon, 15 Nov 2010 12:00:04 -0500
> cmake-requ...@cmake.org wrote:
> 
>> How do you select which of the libraries to use? Based on your
>> Fortran compiler?
> To be exact, based on the Fortran compiler used to build the
> binary-only library.
> 
>> If so, I would check for the CMAKE_Fortran_COMPILER_ID variable and
>> then go on from there.
> Hmm. I've looked at CMakeDetermineFortranCompiler.cmake and it seems to
> me the variable you've mentioned is related to the compiler available
> in the system. Is that correct? If so, I am afraid this is not what I
> need. Consider the following two scenarios:
>  - the system has got both the GNU and the PGI compiler, the library
>variant is for the latter, CMake chooses the former. The program
>fails to build due to resolved PGI symbols;
>  - the system has got both the GNU and the PGI compiler, the library
>variant is for the former, CMake chooses the latter. The program
>ends up unnecessarily linked against PGI run-time libraries,
>possibly causing binary-portability problems.
> 
> I am of course aware I could override CMake's detection routines to
> choose a specific compiler. However, what I would like to do here is
> have the selection happen automatically depending on the variant of the
> binary-only library... Our user base is of the semi-educated sort,
> familiar with the concept of building the software from source but
> tending to run to us with questions when such building doesn't "just
> go".
> 
> Cheers,

That's kind of recursive... I was asking for the criteria by which you
select the binary-only library. But apparently that choice is made by
the "user", right? You have to detect which of the versions he has
installed?

Either go along with Alex' suggestion (or a variation thereof) or do it
the easy way: Define a cache variable (e.g. LIBX_REQUIRES_PGI) and make
it the responsibility of the user to make the choice. Another way would
be to simply require that the user selects the appropriate compiler
according to the library he has. Then you could do a simple try_compile
to find out whether things work and otherwise error out. The user can
select the compiler in various ways, the easiest is to set the FC
environment variable when invoking CMake, e.g:

$ FC=pgf90 cmake /path/to/source

HTH

Michael
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Searching for an undefined symbol in library

2010-11-15 Thread Alexander Neundorf
On Monday 15 November 2010, 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?

You could do the same.

find_library(MY_X_LIB X)
if (MY_X_LIB)
   execute_process(COMMAND nm ${MY_X_LIB}
   COMMAND grep ftn_i_sign
   OUTPUT_VARIABLE _grepOutpout)
   ... check for something in _grepOutput using string() or if( MATCHES)...
endif (MY_X_LIB)

Alex
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Searching for an undefined symbol in library

2010-11-15 Thread Marek Szuba
On Mon, 15 Nov 2010 12:00:04 -0500
cmake-requ...@cmake.org wrote:

> How do you select which of the libraries to use? Based on your
> Fortran compiler?
To be exact, based on the Fortran compiler used to build the
binary-only library.

> If so, I would check for the CMAKE_Fortran_COMPILER_ID variable and
> then go on from there.
Hmm. I've looked at CMakeDetermineFortranCompiler.cmake and it seems to
me the variable you've mentioned is related to the compiler available
in the system. Is that correct? If so, I am afraid this is not what I
need. Consider the following two scenarios:
 - the system has got both the GNU and the PGI compiler, the library
   variant is for the latter, CMake chooses the former. The program
   fails to build due to resolved PGI symbols;
 - the system has got both the GNU and the PGI compiler, the library
   variant is for the former, CMake chooses the latter. The program
   ends up unnecessarily linked against PGI run-time libraries,
   possibly causing binary-portability problems.

I am of course aware I could override CMake's detection routines to
choose a specific compiler. However, what I would like to do here is
have the selection happen automatically depending on the variant of the
binary-only library... Our user base is of the semi-educated sort,
familiar with the concept of building the software from source but
tending to run to us with questions when such building doesn't "just
go".

Cheers,
-- 
MS
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Searching for an undefined symbol in library

2010-11-15 Thread Michael Wild
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
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Searching for an undefined symbol in library

2010-11-15 Thread Marek Szuba
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
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake