Skip to content

SWIG: Build PHP Extensions on Windows with CMake

Hi,

is it possible that CMake 3.12 has a problem generating PHP Extensions on Windows? Here is a screenshot: [cid:image001.png@01D45C20.0CE59B70]

The only thing i did between the two commands was to downgrade to CMake 3.11.4. I saw, there were updates at least on UseSWIG. To reproduce this, you need to build PHP non-thread-safe, download SWIG 3.0.12 and build an example like mine: https://github.com/AlexanderGabriel/SWIGCmakePHPExampleWindows All commands to build this inside a "x64 Native Tools Command Prompt for VS 2017" are:

  • rem build PHP

  • cd C:\ && if exist php-sdk rmdir /s /q C:\php-sdk

  • if not exist C:\php-sdk git clone https://github.com/Microsoft/php-sdk-binary-tools.git C:\php-sdk

  • cd C:\php-sdk

  • set VS_VERSION=%VSCMD_VER:~0,2%

  • phpsdk-vc%VS_VERSION%-%VSCMD_ARG_TGT_ARCH%.bat

  • phpsdk_buildtree phpmaster

  • cd C:\php-sdk\phpmaster\vc%VS_VERSION%%VSCMD_ARG_TGT_ARCH% && if exist php-src rmdir /s /q php-src

  • if not exist C:\php-sdk\phpmaster\vc%VS_VERSION%%VSCMD_ARG_TGT_ARCH%\php-src git clone https://github.com/php/php-src.git "C:\php-sdk\phpmaster\vc%VS_VERSION%%VSCMD_ARG_TGT_ARCH%\php-src"

  • cd C:\php-sdk\phpmaster\vc%VS_VERSION%%VSCMD_ARG_TGT_ARCH%\php-src

  • phpsdk_deps --update --branch master

  • buildconf

  • configure --disable-zts

  • nmake

  • rem download SWIG

  • cd C:\ && if exist not exist projects mkdir projects

  • cd C:\projects && if not exist swigwin-3.0.12 wget http://prdownloads.sourceforge.net/swig/swigwin-3.0.12.zip && unzip swigwin-3.0.12.zip

  • rem Build Example

  • cd C:\projects && if exist SWIGCmakePHPExampleWindows rmdir /s /q C:\projects\SWIGCmakePHPExampleWindows

  • if not exist C:\projects\SWIGCmakePHPExampleWindows git clone https://github.com/AlexanderGabriel/SWIGCmakePHPExampleWindows

  • if exist C:\projects\SWIGCmakePHPExampleWindows\build cd C:\projects\SWIGCmakePHPExampleWindows && rmdir /s /q C:\projects\SWIGCmakePHPExampleWindows\build

  • mkdir C:\projects\SWIGCmakePHPExampleWindows\build

  • cd C:\projects\SWIGCmakePHPExampleWindows\build

  • cmake .. -G "NMake Makefiles" -Wno-dev -DSWIG_EXECUTABLE=C:\projects\swigwin-3.0.12\swig.exe

  • cmake --build . --config Release

If I do this with CMake 3.11.4, it works, with CMake 3.12.3 not. Or am i doing something wrong?

Thank you.

Kind regards, Alex

image001

Edited by Alexander Gabriel
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information