From 896e8d8654694f6e6225fd9a9757652484775ada Mon Sep 17 00:00:00 2001 From: sethg Date: Tue, 23 Feb 2021 00:34:55 +0100 Subject: Add CMake build steps on Windows --- Doc/Manual/Windows.html | 86 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) (limited to 'Doc') diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index f6f0d16df..1991e7fab 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -1,4 +1,4 @@ - + Getting started on Windows @@ -36,6 +36,7 @@
  • Building swig.exe using MinGW and MSYS
  • Building swig.exe using Cygwin
  • Building swig.exe alternatives +
  • Building swig.exe using CMake
  • Running the examples on Windows using Cygwin @@ -364,6 +365,89 @@ SWIG. For example, all the source code files can be added to a Visual C++ projec file in order to build swig.exe from the Visual C++ IDE.

    +

    3.3.1.2 Building swig.exe using Cygwin

    + + +

    +Note that SWIG can also be built using Cygwin. +However, SWIG will then require the Cygwin DLL when executing. +Follow the Unix instructions in the README file in the SWIG root directory. +Note that the Cygwin environment will also allow one to regenerate the autotool generated files which are supplied with the release distribution. +These files are generated using the autogen.sh script and will only need regenerating in circumstances such as changing the build system. +

    + +

    3.3.1.3 Building swig.exe alternatives

    + + +

    +If you don't want to install Cygwin or MinGW, use a different compiler to build +SWIG. For example, all the source code files can be added to a Visual C++ project +file in order to build swig.exe from the Visual C++ IDE. +

    + +

    3.3.1.4 Building swig.exe using CMake

    + + +

    +SWIG can also be built using CMake and Visual Studio rather than autotools. As with the other approaches to +building SWIG the dependencies need to be installed. The steps below are one of a number of ways of installing the dependencies without requiring Cygwin or MinGW. +For fully working build steps always check the Continuous Integration setups currently detailed in the Appveyor YAML file. +

    + +
      +
    1. + Download CMake from https://cmake.org/download/. In this example we are using 3.19 and unzipping it + to C:\Tools\cmake-3.19.4-win64-x64 +
    2. +
    3. + Download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) + and save to a folder e.g. C:\Tools\Bison +
    4. +
    5. + Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example). Nuget is the package manager + for .NET, but allows us to easily install PCRE required by SWIG. +
    6. +
    7. + Install PCRE using Nuget using the following command:
      C:\Tools\nuget install pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre
      +
    8. +
    9. + We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase + using
      git clone https://github.com/swig/swig.git
      + In this example we are assuming the source code is available at C:\swig +
    10. +
    + +

    +Now we have all the required dependencies we can build SWIG using the commands below. We add the required build tools to the system PATH, and then +build a Release version of SWIG. +

    + +
    +
    +cd C:\swig
    +SET PATH=C:\Tools\cmake-3.19.4-win64-x64\bin;C:\Tools\Bison\bin;%PATH%
    +PCRE_ROOT=C:/pcre/pcre.8.33.0.1/build/native
    +SET PCRE_PLATFORM=x64
    +cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include 
    +-DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/Tools/Bison/bin/bison.exe .
    +cmake --build . --config Release
    +
    +
    + +

    + If all runs successfully a new swig.exe should be generated in a /Release folder. + In addition to Release builds you can create a Debug build using: +

    +
    +
    cmake --build . --config Debug
    +
    +

    + A Visual Studio solution file should be generated - swig.sln. This can be opened and debugged by running the swig project and setting the + Debugging Command Arguments. For example to step through one of the sample .i files included with the SWIG source use the following: +

    +
    +
    -python -py3 -shadow -o C:\Temp\doxygen_parsing.c C:\swig\Examples\test-suite\doxygen_parsing.i
    +

    3.3.2 Running the examples on Windows using Cygwin

    -- cgit v1.2.1 From da33383ea26991cde94cc2d2a1afee61008c0547 Mon Sep 17 00:00:00 2001 From: sethg Date: Tue, 23 Feb 2021 00:38:41 +0100 Subject: Add link on main Contents page --- Doc/Manual/Contents.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Doc') diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 79ffdd50e..59378c50b 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1,4 +1,4 @@ - + @@ -98,6 +98,7 @@
  • Building swig.exe using MinGW and MSYS
  • Building swig.exe using Cygwin
  • Building swig.exe alternatives +
  • Building swig.exe using CMake
  • Running the examples on Windows using Cygwin -- cgit v1.2.1 From a1fdfe7d657cdc343868beaf6ea9f15a0311fe93 Mon Sep 17 00:00:00 2001 From: sethg Date: Tue, 23 Feb 2021 12:49:30 +0100 Subject: Remove duplicate section --- Doc/Manual/Windows.html | 51 ++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) (limited to 'Doc') diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index 1991e7fab..e23af9e75 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -356,15 +356,6 @@ Note that the Cygwin environment will also allow one to regenerate the autotool These files are generated using the autogen.sh script and will only need regenerating in circumstances such as changing the build system.

    -

    3.3.1.3 Building swig.exe alternatives

    - - -

    -If you don't want to install Cygwin or MinGW, use a different compiler to build -SWIG. For example, all the source code files can be added to a Visual C++ project -file in order to build swig.exe from the Visual C++ IDE. -

    -

    3.3.1.2 Building swig.exe using Cygwin

    @@ -394,27 +385,27 @@ building SWIG the dependencies need to be installed. The steps below are one of For fully working build steps always check the Continuous Integration setups currently detailed in the Appveyor YAML file.

    -
      -
    1. - Download CMake from https://cmake.org/download/. In this example we are using 3.19 and unzipping it - to C:\Tools\cmake-3.19.4-win64-x64 -
    2. -
    3. - Download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) - and save to a folder e.g. C:\Tools\Bison -
    4. -
    5. - Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example). Nuget is the package manager - for .NET, but allows us to easily install PCRE required by SWIG. -
    6. -
    7. - Install PCRE using Nuget using the following command:
      C:\Tools\nuget install pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre
      -
    8. -
    9. - We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase - using
      git clone https://github.com/swig/swig.git
      - In this example we are assuming the source code is available at C:\swig -
    10. +
        +
      1. + Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example). Nuget is the package manager + for .NET, but allows us to easily install PCRE required by SWIG. +
      2. +
      3. + Download CMake from https://cmake.org/download/. In this example we are using 3.19 and unzipping it + to C:\Tools\cmake-3.19.4-win64-x64 +
      4. +
      5. + Download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) + and save to a folder e.g. C:\Tools\Bison +
      6. +
      7. + Install PCRE using Nuget using the following command:
        C:\Tools\nuget install pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre
        +
      8. +
      9. + We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase + using
        git clone https://github.com/swig/swig.git
        + In this example we are assuming the source code is available at C:\swig +

      -- cgit v1.2.1 From f0bf789db098f3730e859a778be3ec29fb4b7f7e Mon Sep 17 00:00:00 2001 From: sethg Date: Tue, 23 Feb 2021 13:16:07 +0100 Subject: Remove duplicate and update to nuget installs --- Doc/Manual/Windows.html | 76 +++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 41 deletions(-) (limited to 'Doc') diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index e23af9e75..065da215d 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -348,17 +348,6 @@ make

      3.3.1.2 Building swig.exe using Cygwin

      -

      -Note that SWIG can also be built using Cygwin. -However, SWIG will then require the Cygwin DLL when executing. -Follow the Unix instructions in the README file in the SWIG root directory. -Note that the Cygwin environment will also allow one to regenerate the autotool generated files which are supplied with the release distribution. -These files are generated using the autogen.sh script and will only need regenerating in circumstances such as changing the build system. -

      - -

      3.3.1.2 Building swig.exe using Cygwin

      - -

      Note that SWIG can also be built using Cygwin. However, SWIG will then require the Cygwin DLL when executing. @@ -385,55 +374,60 @@ building SWIG the dependencies need to be installed. The steps below are one of For fully working build steps always check the Continuous Integration setups currently detailed in the Appveyor YAML file.

      -
        -
      1. - Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example). Nuget is the package manager - for .NET, but allows us to easily install PCRE required by SWIG. -
      2. -
      3. - Download CMake from https://cmake.org/download/. In this example we are using 3.19 and unzipping it - to C:\Tools\cmake-3.19.4-win64-x64 -
      4. -
      5. - Download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) - and save to a folder e.g. C:\Tools\Bison -
      6. -
      7. - Install PCRE using Nuget using the following command:
        C:\Tools\nuget install pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre
        -
      8. -
      9. - We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase - using
        git clone https://github.com/swig/swig.git
        - In this example we are assuming the source code is available at C:\swig -
      10. +
          +
        1. + Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example, and installed to C:\Tools). Nuget is the package manager + for .NET, but allows us to easily install PCRE and other dependencies required by SWIG. +
        2. +
        3. + Install CMake using the following command:
          C:\Tools\nuget install CMake-win64 -Version 3.15.5 -OutputDirectory C:\Tools\CMake
          + Alternatively you can download CMake from https://cmake.org/download/. +
        4. +
        5. + Install Bison using the following command:
          C:\Tools\nuget install bison-win32 -Version 2.4.1.1 -OutputDirectory C:\Tools\bison
          + Alternatively download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) + and save to a folder e.g. C:\Tools\Bison +
        6. +
        7. + Install PCRE using Nuget using the following command:
          C:\Tools\nuget install pcre -Version 8.33.0.1 -OutputDirectory C:\Tools\pcre
          +
        8. +
        9. + We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase + using
          git clone https://github.com/swig/swig.git
          + In this example we are assuming the source code is available at C:\swig +

        -Now we have all the required dependencies we can build SWIG using the commands below. We add the required build tools to the system PATH, and then -build a Release version of SWIG. + We are assuming Visual Studio 2017 is installed. For other versions of Visual Studio change "Visual Studio 15 2017 Win64" to the relevant + Visual Studio Generator. + Now we have all the required dependencies we can build SWIG using the commands below. We add the required build tools to the system PATH, and then + build a Release version of SWIG. If all runs successfully a new swig.exe should be generated in a /Release folder.

        -
        +    
         cd C:\swig
        -SET PATH=C:\Tools\cmake-3.19.4-win64-x64\bin;C:\Tools\Bison\bin;%PATH%
        -PCRE_ROOT=C:/pcre/pcre.8.33.0.1/build/native
        +SET PATH=C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\bison-win32.2.4.1.1\tools\native\bin;%PATH%
        +SET PCRE_ROOT=C:\Tools\pcre\pcre.8.33.0.1\build\native
         SET PCRE_PLATFORM=x64
        -cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include 
        --DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/Tools/Bison/bin/bison.exe .
        +cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib .
         cmake --build . --config Release
        +
        +REM to test the exe
        +cd /Release
        +swig.exe -help
         

        - If all runs successfully a new swig.exe should be generated in a /Release folder. In addition to Release builds you can create a Debug build using:

        cmake --build . --config Debug

        - A Visual Studio solution file should be generated - swig.sln. This can be opened and debugged by running the swig project and setting the + A Visual Studio solution file should be generated named swig.sln. This can be opened and debugged by running the swig project and setting the Debugging Command Arguments. For example to step through one of the sample .i files included with the SWIG source use the following:

        -- cgit v1.2.1