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 <>
Date: Sat, 02 Jan 2016 01:35:57 +0100

Alexander Lamaison in (Fri, 1 Jan 2016
15:46:41 +0000):
>On 21 December 2015 at 10:32, Jan Ehrhardt <> wrote:
>> The VC-projects are used for compiling libssh2 as a dependency for PHP 5
>> and PHP 7:
>> I would not advice to remove them.
>Could PHP not use VC projects via CMake?

TLDR: CMake sort of works

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

But the same trick for Zlib did not work:

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

Outcome of
CMake -G"Visual Studio 14 2015 Win64" -D"BUILD_SHARED_LIBS=1"

 * Shared library , creating libssh2 as a shared library (.so/.dll)
 * diffie-hellman-group-exchange-sha1 ,
     "new" diffie-hellman-group-exchange-sha1 method

-- The following OPTIONAL packages have been found:

 * OpenSSL

-- The following features have been disabled:

 * Compression , using zlib for compression
 * "none" cipher
 * "none" MAC
 * Logging , Logging of execution with debug trace

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:


In short: CMake sort of works, but it disables things like zlib which you
do not want to be disabled. And manually editing libssh2_config.h to
#define HAVE_SNPRINTF is really ugly. Also you will have to rerun CMake 4
times to get all dll's and lib's (static/shared + x86/x64).

BTW: I also try to leave out ZLIB_ROOT or set ZLIB_ROOT_DIR although the
CMake docs say it should be ZLIB_ROOT:

Received on 2016-01-02