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 01:35:57 +0100

Alexander Lamaison in gmane.network.ssh.libssh2.devel (Fri, 1 Jan 2016
15:46:41 +0000):
>On 21 December 2015 at 10:32, Jan Ehrhardt <phpdev_at_ehrhardt.nl> wrote:
>> The VC-projects are used for compiling libssh2 as a dependency for PHP 5
>> and PHP 7: https://github.com/winlibs/libssh2
>>
>> 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:
-D"ZLIB_ROOT=/php-sdk/win64build.vc14"

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"
   -D"OPENSSL_ROOT_DIR=/php-sdk/win64build.vc14"
   -D"ZLIB_ROOT=/php-sdk/win64build.vc14"

 * 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:

    ZLIB_ROOT

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:
https://cmake.org/cmake/help/v3.0/module/FindZLIB.html

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