FindGnutls.cmake troubles with Windows

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

FindGnutls.cmake troubles with Windows

Dixon, Shane

I’m having some trouble getting FindGnutls.cmake working correctly.  As it currently stands, I run cmake twice and it works correctly, but it never picks up the gnutls.h on the first scan.  Here’s the code in question (the entire FindGnutls.cmake is at the end of this email):

 

FIND_PATH(GNUTLS_INCLUDE_DIR gnutls/gnutls.h

   HINTS

   ${PC_GNUTLS_INCLUDEDIR}

   ${PC_GNUTLS_INCLUDE_DIRS}

   "C:/Program Files/*/include"   )

 

For some reason it never finds gnutls.h. I get an error saying it can’t be found.  I added the C:/ line because I didn’t know how else to make it find the file. How should I be doing this?  What’s considered the proper way to find this without hard-coding a path?  Gnutls is kind of annoying in that it has the version number in it’s install directory (i.e. c:\Program Files\Gnutls-2.8.2 and c:\Program Files\Gnutls-2.9.5).  This makes it harder to hard-code the path.  The correct path that this should return is “c:\Program Files\GnuTLS-2.8.2\gnutls\”

 

--

Shane

 

 

 

==== FindGnutls.cmake ========

# - Try to find the GNU Transport Layer Security library (gnutls)

#

# Once done this will define

#

#  GNUTLS_FOUND - System has gnutls

#  GNUTLS_INCLUDE_DIR - The gnutls include directory

#  GNUTLS_LIBRARIES - The libraries needed to use gnutls

#  GNUTLS_DEFINITIONS - Compiler switches required for using gnutls

 

# Adapted from FindXml2.cmake, which is:

#   Copyright (c) 2006, Alexander Neundorf, <[hidden email]>

#

# Changes are Copyright 2009, Brad Hards, <[hidden email]>

#             Copyright 2009, Philip Lowman, <[hidden email]>

#

# Redistribution and use is allowed according to the terms of the BSD license.

# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

#

# Note that this doesn't try to find the gnutls-extra package.

 

 

IF (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARY)

   # in cache already

   SET(gnutls_FIND_QUIETLY TRUE)

ENDIF (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARY)

 

IF (NOT WIN32)

   # try using pkg-config to get the directories and then use these values

   # in the FIND_PATH() and FIND_LIBRARY() calls

   # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful

   FIND_PACKAGE(PkgConfig)

   PKG_CHECK_MODULES(PC_GNUTLS gnutls)

   SET(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})

ELSE ( WIN32 )

   MESSAGE( STATUS "If you're generating a MSVC environment, you'll need to run the command" )

   MESSAGE( STATUS " C:\\Program Files\\GnuTLS-2.8.2\\bin>lib /def:libgnutls-26.def /nologo /machine:x86" )

   MESSAGE( STATUS "From the MSVC command prompt to generate the .lib file and copy it into" )

   MESSAGE( STATUS "your lib folder." )

ENDIF (NOT WIN32)

 

FIND_PATH(GNUTLS_INCLUDE_DIR gnutls/gnutls.h

   HINTS

   ${PC_GNUTLS_INCLUDEDIR}

   ${PC_GNUTLS_INCLUDE_DIRS}

   "C:/Program Files/*/include"   )

 

FIND_LIBRARY(GNUTLS_LIBRARY NAMES gnutls libgnutls libgnutls-26

   HINTS

   ${PC_GNUTLS_LIBDIR}

   ${PC_GNUTLS_LIBRARY_DIRS}

   )

 

# handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if

# all listed variables are TRUE

INCLUDE(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS DEFAULT_MSG GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR)

 

MARK_AS_ADVANCED(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY)

 

SET(GNUTLS_LIBRARIES    ${GNUTLS_LIBRARY})

SET(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: FindGnutls.cmake troubles with Windows

Philip Lowman
On Tue, Sep 29, 2009 at 4:43 PM, Dixon, Shane <[hidden email]> wrote:

I’m having some trouble getting FindGnutls.cmake working correctly.  As it currently stands, I run cmake twice and it works correctly, but it never picks up the gnutls.h on the first scan.  Here’s the code in question (the entire FindGnutls.cmake is at the end of this email):

 

FIND_PATH(GNUTLS_INCLUDE_DIR gnutls/gnutls.h

   HINTS

   ${PC_GNUTLS_INCLUDEDIR}

   ${PC_GNUTLS_INCLUDE_DIRS}

   "C:/Program Files/*/include"   )

What you typed above isn't supported by find_path (doesn't support wildcards).

If you want it to work automatically your best option at the moment is probably to set (as an environment variable or a CMake variable) CMAKE_PREFIX_PATH to C:/Program Files/Gnutls-2.8.x where x is the version you are using.

The GnuTLS installer does set a registry key which normally could be used to help searching for this library...
\\HKLM\SOFTWARE\GnuTLS-2.8.4\Install_Dir
...but it is also version encumbered.

--
Philip Lowman

_______________________________________________
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