[CMake] How to find dll's on Cygwin? (fwd)

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri Oct 27 03:32:42 EDT 2017


I am pretty sure there are a non-zero number of CMake users here who
have had CMake experience finding dll's on Cygwin (since it appears
from the quote below that import libraries can be replaced by dll's
for the purposes of linking on that platform).  So if you are one with
such experience, I would really appreciate an answer to (or commment
on) the specific question below concerning finding cyggnat-6.dll on
Cygwin or if you prefer to frame your response to the more general
question of finding dll's on that platform, that would be great as
well.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

---------- Forwarded message ----------
Date: Wed, 25 Oct 2017 01:10:25 -0700 (PDT)
From: Alan W. Irwin <irwin at beluga.phys.uvic.ca>
To: cmake at cmake.org
Subject: [CMake] How to find dll's on Cygwin?

What CMake logic should be used to find the Cygwin dll

/usr/bin/cyggnat-6.dll

?

I don't have access to Cygwin myself, but my PLplot colleague, Arjen
Markus who does have such access has reported to me off-list that

find_library(GNAT_LIB NAMES gnat gnat-${GNAT_VERSION} 
gnat-${GNAT_MAJOR_VERSION} cyggnat-${GNAT_MAJOR_VERSION})

does not find /usr/bin/cyggnat-6.dll [for the case tested where
${GNAT_MAJOR_VERSION} was confirmed to be 6].
Note that find was a failure even when he included /usr/bin in
CMAKE_LIBRARY_PATH .

To find dll's this way (rather than import libraries) do I have to use
find_file instead, e.g.,

# Take care of non-Cygwin cases:
find_library(GNAT_LIB NAMES gnat gnat-${GNAT_VERSION} 
gnat-${GNAT_MAJOR_VERSION})
# Take care of Cygwin case. (Note /usr/bin does not have to be added to
# CMAKE_LIBRARY_PATH for this case.)
find_file(GNAT_LIB NAMES cyggnat-${GNAT_MAJOR_VERSION}.dll)

?

Or is there some slick way to accommodate both non-Cygwin and Cygwin
platforms with one call to find_library?

<Aside> For a long time it puzzled Arjen and me that our test_ada
project Ada library could be linked with the above dll by hand when
normally you use an import library for that purpose.  But we were
forced to try that because the Cygwin distribution does not provide an
import library corresponding to /usr/bin/cyggnat-6.dll.  And it worked
by hand so now we have to convince CMake to do the same starting with
finding the dll to be used to link our Ada library.

Note the reason why the dll can be used this way is explained with the
following quote from
<https://stackoverflow.com/questions/3573475/how-does-the-import-library-work-details>:

"If you use the GCC toolchain, incidentally, you don't actually need
import libraries to match your DLLs. The version of the Gnu linker
ported to Windows understands DLLs directly, and can synthesize most
any required stubs on the fly."

</Aside>

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list