www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: Removing non-CMake windows support (was Re: problems building under Windows)

Re: Removing non-CMake windows support (was Re: problems building under Windows)

From: Jan Ehrhardt <phpdev_at_ehrhardt.nl>
Date: Sat, 02 Jan 2016 18:10:15 +0100

Alexander Lamaison in gmane.network.ssh.libssh2.devel (Sat, 2 Jan 2016
11:12:02 +0000):
>On 2 January 2016 at 00:35, Jan Ehrhardt <phpdev_at_ehrhardt.nl> wrote:
>> CMake (on Windows) is notoriously stubborn when it comes to finding
>> libraries. I had to upgrade to CMake 3.4.1 (was 3.2.2) to be able to
>> manually specify the location of the OpenSSL library:
>> -D"OPENSSL_ROOT_DIR=/php-sdk/win64build.vc14" for 64-bits VC14 libs
>> -D"OPENSSL_ROOT_DIR=/php-sdk/win64build.vc11" for 64-bits VC11 libs
>
>With CMake 3.2, what was happening? Was it failing to find any
>OpenSSL, or was it finding the wrong one?

I later discovered that it wasn't the upgrade to CMake 3.4.1 that made the
real difference, but the fact that I uninstalled OpenSSL on my system. I
had it installed with the installers of
https://slproweb.com/products/Win32OpenSSL.html and then CMake prefers the
system wide OpenSSL, no matter what you specify manually. It just
disregarded OPENSSL_ROOT_DIR. See the snippet from FindOpenSSL.cmake
below. In my case it found C:\OpenSSL\Win32\1_0_2d because the registry
key pointed to that location. The difference between 3.2.2 and 3.4.1 was
that 3.2.2 always used the 32-bits key and 3.4.1 was smart enough to use
the 64-bits key when building for Win64.

>> Moreover CMake falsely #undef's HAVE_SNPRINTF in VC14. VC14 aka VS2015
>> does have a snprintf, so you will have to manually add #define
>> HAVE_SNPRINTF to libssh2_config.h
>
>Are you using the latest from git? This should have been fixed in
>https://github.com/libssh2/libssh2/commit/af14462d535a2b061a77d31d60734ebb558aca16

I used the 1.6.0 release tarball. Did not check git head yet.

Jan

Snippet from FindOpenSSL.cmake:

if (WIN32)
  # http://www.slproweb.com/products/Win32OpenSSL.html
  set(_OPENSSL_ROOT_HINTS
    ${OPENSSL_ROOT_DIR}

"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL
      (32-bit)_is1;Inno Setup: App Path]"

"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL
      (64-bit)_is1;Inno Setup: App Path]"
    ENV OPENSSL_ROOT_DIR
    )
  file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
  set(_OPENSSL_ROOT_PATHS
    "${_programfiles}/OpenSSL"
    "${_programfiles}/OpenSSL-Win32"
    "${_programfiles}/OpenSSL-Win64"
    "C:/OpenSSL/"
    "C:/OpenSSL-Win32/"
    "C:/OpenSSL-Win64/"
    )
  unset(_programfiles)
else ()
  set(_OPENSSL_ROOT_HINTS
    ${OPENSSL_ROOT_DIR}
    ENV OPENSSL_ROOT_DIR
    )
endif ()

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2016-01-02

the libssh2 team