[Cmake] FIND_LIBRARY : question about name

ibiris at genius.org.br ibiris at genius.org.br
Mon, 26 Apr 2004 11:26:07 -0400


OK

I am trying to use the windows version of CMake in both windows and cygwi=
n=20
environments. For windows I use the "NMake Makefiles" generator and for=20
cygwin the "Unix Makefiles" generator.

Here is a little diagram of dependencies

TOP-LEVEL=20
        ---- COMPONENT X
                Makes library libx.a or x.lib (cygwin/windows=20
respectively)

        ---- COMPONENT Y
                Makes library liby.so or y.dll + y.lib. This library=20
requires to link to the library in component X



I tried to use ADD_DEPENDENCY but it did not work (I did not get the=20
library in component X). So I hacked a solution trying to build the=20
library in component A when I do cmake in component Y. I used the=20
following bit of code in the CMakeLists.txt that is responsible for makin=
g=20
the library in ComponentY.


---------------
FIND_LIBRARY(libX NAMES x PATHS=20
${COMPONENTY_SOURCE_DIR}/../ComponentX/build/bin)

#If the library in component X does not exist
IF( NOT libX)

# Warn some
  MESSAGE( "WARNING:: missing library X for generator ${CMAKE_GENERATOR}"=
)
  MESSAGE( "WARNING:: will try to create it in=20
${COMPONENTY_SOURCE_DIR}/../ComponentX/build")

# try to get it created
# make directory build=20
  MAKE_DIRECTORY(${COMPONENTY_SOURCE_DIR}/../ComponentX/build)

#do cmake with the same generator as used for componentY
  EXEC_PROGRAM(${CMAKE_COMMAND}=20
${COMPONENTY_SOURCE_DIR}/../ComponentX/build ARGS -G"${CMAKE_GENERATOR}"=20
..)

# Do make or nmake
  EXEC_PROGRAM(${CMAKE_MAKE_PROGRAM}=20
${COMPONENTY_SOURCE_DIR}/../ComponentX/build)

# try to find the library again ... if not there cmake fails this time fo=
r=20
sure
  FIND_LIBRARY(libX NAMES x PATHS=20
${COMPONENTY_SOURCE_DIR}/../ComponentX/build/bin)
ENDIF(NOT libX)
---------------


I do not claim this code is the best but I expected it to work at least=20
until some better solution was worked out. On cygwin (with the contents o=
f=20
ComponentX/build directory completely removed) it goes on to build=20
ComponentX library successfully, while it is configuring the component Y=20
stuff, but the second 'find_library' fails. On windows it does the build=20
of ComponentX library and the second  'find_library' works fine.=20

I also tried varying the names of the libraries in windows and cygwin to=20
see if there is a difference, but it did not work. I suspect now that it=20
must be the fact that I am using windows cmake (1.8.3). I expected that=20
cmake would find the correct library names depending the type of the=20
generator.




----
Ilias Biris, Ph.D.
Senior Researcher
Genius Instituto de Tecnologia
TEL: +55 (0)92 6146503
FAX: +55 (0)92 6133144
http://www.genius.org.br/





"William A. Hoffman" <billlist at nycap.rr.com>
Sent by: cmake-admin at www.cmake.org
26/04/2004 11:02

=20
        To:     ibiris at genius.org.br, cmake at www.cmake.org
        cc:=20
        Subject:        Re: [Cmake] FIND_LIBRARY : question about name


The cygwin cmake looks for libx for me?
Can you give an example?=20


If this did not work, then cmake itself would not build under cygwin,
since it needs to find curses and form libraries:

CURSES_LIBRARY:FILEPATH=3D/usr/lib/libcurses.a
//Where can the form library be found
FORM_LIBRARY:FILEPATH=3D/usr/lib/libform.a

-Bill

At 10:15 AM 4/23/2004, ibiris at genius.org.br wrote:




>Hello folks,
>
>recently I tried to use FIND_LIBRARY to check if a library required to
>build  another library is already available or it has to be built first.
>
>The problem I have is that the name of the library is libx.a in cygwin=20
but
>just x.lib on windows. Using just
>
>FIND_LIBRARY(varname NAMES x PATHS < bunch o' paths here> )
>
>works ok on windows but on cygwin it causes an error, since it cannot=20
find
>the libx (instead of x). Can someone verify if I need to search for a
>different name in  cygwin / windows / Linux?  I would expect that 'x'=20
marks
>the name that is used for linking so it should look for x.lib on windows
>and libx.a for linux/cygwin.
>
>Maybe I am missing something so your help would be greatfully=20
appreciated.
>
>Kind regards,
>
>----
>Ilias Biris, Ph.D.
>Senior Researcher
>Genius Instituto de Tecnologia
>TEL: +55 (0)92 6146503
>FAX: +55 (0)92 6133144
>http://www.genius.org.br/
>************************************************************************=
**************************
>
>O conte=FAdo desse e-mail ou de seus anexos s=E3o confidenciais e restri=
tos=20
ao=20
>destinat=E1rio da mensagem.
>Se voc=EA recebeu esse e-mail por engano, por favor notifique o remetent=
e=20
>imediatamente e n=E3o fa=E7a c=F3pias ou distribua seu conte=FAdo para n=
ingu=E9m.
>
>************************************************************************=
**************************
>
>The contents of this email and any attachments are confidential.
>They are intended for the named recipient(s) only.
>If you have received this email in error please notify the system manage=
r=20
or  the=20
>sender immediately and do not disclose the contents to anyone or make=20
copies.
>
>************************************************************************=
**************************
>_______________________________________________
>Cmake mailing list
>Cmake at www.cmake.org
>http://www.cmake.org/mailman/listinfo/cmake=20

_______________________________________________
Cmake mailing list
Cmake at www.cmake.org
http://www.cmake.org/mailman/listinfo/cmake


*************************************************************************=
*************************

O conte=FAdo desse e-mail ou de seus anexos s=E3o confidenciais e restrit=
os ao=20
destinat=E1rio da mensagem.
Se voc=EA recebeu esse e-mail por engano, por favor notifique o remetente=
=20
imediatamente e n=E3o fa=E7a c=F3pias ou distribua seu conte=FAdo para ni=
ngu=E9m.

*************************************************************************=
*************************

The contents of this email and any attachments are confidential.
They are intended for the named recipient(s) only.
If you have received this email in error please notify the system manager=
 or  the=20
sender immediately and do not disclose the contents to anyone or make cop=
ies.

*************************************************************************=
*************************