← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Github support for mingw-w64

 

Hi Brian,

You have a total comprehension of what is going on, and your solution has left the linux
build working.  So I would say thank you for an excellent job.  I would hope windows users
would say the same.

Comments below.

On 10/05/2013 09:19 AM, Brian Sidebotham wrote:
> Hi Guys,
> 
> Attached is the current patch I can commit to enable Github plugin support for MinGW.
> 
> It enables OpenSSL, which can be pointed to by setting the OPENSSL_ROOT_DIR when
> configuring with CMake. I've not done any work on getting OpenSSL to compile under windows
> as it cross-compiles under Linux just fine.
> 
> The boost build steps are a bit different to Linux and OSX. On windows we need to specify
> library subsets to b2 rather than bootstrap using a --with- prefix for all required libraries.
> 
> The installation of boost headers is slightly different under MinGW too, we end up with an
> include directory of ${BOOST_ROOT}/include/boost-1_54/ instead of just the include base
> directory.
> 
> There were some linking problems with github where I had to add ${wxWidgets_LIBRARIES}. I
> guess that is safe to do across all platforms? boost::asio requires us to link in a socket
> layer under MinGW too, so ws2_32 is added for MinGW only.


target_link_libraries() is additive, can be called many times without overwriting previous
settings.  So we should probably change the way you are doing the MINGW
ws2_32.  See below.


> 
> Dick, if you've got time to review, could you give me your views and any suggestions for
> change?
> 
> I should also add - this will not work with mingw32 as far as I have tested. The
> compilation of a subset of boost libraries does not work for me under the mingw32. This is
> probably a major problem as I expect most people who are using MinGW are still using the
> MinGW32 project and not the mingw-w64 project. With mingw32 using dwarf-2 though it
> doesn't really make any sense to me to use that project.
> 
> Best Regards,
> 
> Brian.
> 
> github-mingw.diff
> 
> 
> === modified file 'CMakeLists.txt'
> --- CMakeLists.txt	2013-09-23 15:19:39 +0000
> +++ CMakeLists.txt	2013-10-05 14:01:22 +0000
> @@ -53,14 +53,7 @@
>  
>  option( USE_FP_LIB_TABLE "Use the new footprint library table implementation. ( default OFF)" )
>  
> -# BUILD_GITHUB_PLUGIN for MINGW is pretty demanding due to download_openssl.cmake and openssl's
> -# use of perl to drive its configure step.  You might find it works in a cross builder say on linux.
> -# Dick is not personally supporting Windows any more with this exotic stuff.  Some other windows
> -# developer will have to smooth out the build issues.  So enable this for MINGW without my help but
> -# with my best wishes.
> -if( NOT MINGW )
> -    option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF )
> -endif()
> +option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF )
>  
>  
>  #Set version option (stable or testing)
> 
> === modified file 'CMakeModules/download_boost.cmake'
> --- CMakeModules/download_boost.cmake	2013-09-23 15:19:39 +0000
> +++ CMakeModules/download_boost.cmake	2013-10-05 14:00:23 +0000
> @@ -87,21 +87,27 @@
>  
>      # It will probably be simpler to make this the only path in the future.
>  
> -    # (BTW "test" yields "unit_test_framework" when passed to bootstrap.{sh,bat} ).
> +    # (BTW "test" yields "unit_test_framework" when passed to bootstrap.sh ).
>      #message( STATUS "BOOST_LIBS_BUILT:${BOOST_LIBS_BUILT}" )
> -    string( REPLACE "unit_test_framework" "test" libs_csv "${BOOST_LIBS_BUILT}" )
> -    #message( STATUS "REPLACE libs_csv:${libs_csv}" )
> -
> -    string( REGEX REPLACE "\\;" "," libs_csv "${libs_csv}" )
> -    #message( STATUS "libs_csv:${libs_csv}" )
> +    string( REPLACE "unit_test_framework" "test" boost_libs_list "${BOOST_LIBS_BUILT}" )
> +    #message( STATUS "REPLACE libs_csv:${boost_libs_list}" )
>  
>      if( MINGW )
> -        set( bootstrap "bootstart.bat mingw" )
> +        set( bootstrap bootstrap.bat mingw )
> +
> +        foreach( lib ${boost_libs_list} )
> +            set( b2_libs ${b2_libs} --with-${lib} )
> +        endforeach()
>          unset( PIC_STUFF )
>      else()
> -        set( bootstrap bootstrap.sh )
> +        string( REGEX REPLACE "\\;" "," libs_csv "${boost_libs_list}" )
> +        #message( STATUS "libs_csv:${libs_csv}" )
> +
> +        set( bootstrap bootstrap.sh --with-libraries=${libs_csv} )
>          # pass to *both* C and C++ compilers
>          set( PIC_STUFF "cflags=${PIC_FLAG}" )
> +        set( BOOST_INCLUDE "${BOOST_ROOT}/include" )
> +        unset( b2_libs )
>      endif()
>  
>      ExternalProject_Add( boost
> @@ -120,13 +126,13 @@
>  
>          BINARY_DIR      "${PREFIX}/src/boost/"
>          CONFIGURE_COMMAND ./${bootstrap}
> -                        --with-libraries=${libs_csv}
>  
>          BUILD_COMMAND   ./b2
>                          variant=release
>                          threading=multi
>                          toolset=gcc
>                          ${PIC_STUFF}
> +                        ${b2_libs}
>                          #link=static
>                          --prefix=<INSTALL_DIR>
>                          install
> @@ -134,12 +140,35 @@
>          INSTALL_COMMAND ""
>          )
>  
> +    if( MINGW )
> +        execute_process( COMMAND ${CMAKE_C_COMPILER} -dumpversion
> +            OUTPUT_VARIABLE GCC_VERSION
> +            OUTPUT_STRIP_TRAILING_WHITESPACE )
> +
> +        string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.[0-9]+.*" "\\1\\2" BOOST_GCC_VERSION ${GCC_VERSION} )
> +        #message( STATUS "BOOST_GCC_VERSION: ${BOOST_GCC_VERSION}" )
> +
> +        string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9])" "\\1_\\2" BOOST_LIB_VERSION ${BOOST_RELEASE} )
> +        #message( STATUS "BOOST_LIB_VERSION: ${BOOST_LIB_VERSION}" )
> +
> +        # adjust the names of the libraries to suit the build. There's no
> +        # symbolic links provided on the MinGW build to allow us to use
> +        # generic names for the libs
> +        foreach( lib ${BOOST_LIBS_BUILT} )
> +            set( mingw_boost_libs ${mingw_boost_libs} ${lib}-mgw${BOOST_GCC_VERSION}-mt-${BOOST_LIB_VERSION} )
> +        endforeach()
> +
> +        set( BOOST_LIBS_BUILT ${mingw_boost_libs} )
> +        set( BOOST_INCLUDE "${BOOST_ROOT}/include/boost-${BOOST_LIB_VERSION}" )
> +        unset( mingw_boost_libs )
> +    endif()
> +
>      set( boost_libs "" )
>      set_boost_lib_names( "${BOOST_LIBS_BUILT}" boost_libs )
>      #message( STATUS "BOOST_ROOT:${BOOST_ROOT}  boost_libs:${boost_libs}" )
> -    set( Boost_LIBRARIES    ${boost_libs}           CACHE FILEPATH "Boost libraries directory" )
> -    set( Boost_INCLUDE_DIR  "${BOOST_ROOT}/include" CACHE FILEPATH "Boost include directory" )
> -
> +    set( Boost_LIBRARIES    ${boost_libs}      CACHE FILEPATH "Boost libraries directory" )
> +    set( Boost_INCLUDE_DIR  "${BOOST_INCLUDE}" CACHE FILEPATH "Boost include directory" )
> +    #message( STATUS "Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}" )
>  
>  else( BUILD_GITHUB_PLUGIN )
>  
> 
> === modified file 'pcbnew/github/CMakeLists.txt'
> --- pcbnew/github/CMakeLists.txt	2013-09-21 19:20:31 +0000
> +++ pcbnew/github/CMakeLists.txt	2013-10-04 23:04:56 +0000
> @@ -26,7 +26,7 @@
>  #################################################
>  include( download_avhttp )
>  
> -if( MINGW )
> +if( MINGW AND NOT OPENSSL_ROOT_DIR )
>      # download, compile and install to scratch dir a recent OPENSSL library and headers
>      include( download_openssl )
>  else()
> @@ -58,10 +58,16 @@
>      github_plugin.cpp
>      )
>  

Remove this if() block:

> +if( MINGW )
> +    set( GITHUB_ADDITIONAL_LIBS ws2_32 )
> +endif()
> +
>  # No, you don't get github without boost and openssl
>  target_link_libraries( github_plugin
>      ${Boost_LIBRARIES}
>      ${OPENSSL_LIBRARIES}
> +    ${wxWidgets_LIBRARIES}

remove this:
> +    ${GITHUB_ADDITIONAL_LIBS}
>      )

and replace it with this trailing additive statement:

if( MINGW )
target_link_libraries( github_plugin
    ws2_32
    )
endif()

>  
>  add_dependencies( github_plugin boost )
> 
> 
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 



Follow ups

References