← Back to team overview

kicad-developers team mailing list archive

Re: OpenSSL-CMake build system

 

On 10/22/2013 04:57 PM, Brian Sidebotham wrote:
> Hi Guys,
> 
> I attach a diff which uses a new OpenSSL-CMake project I registered on Launchpad to
> provide a CMake build system on-top of OpenSSL. I started with the LuaDist project's CMake
> system and patched it to work with the OpenSSL 1.0.1e release.
> 
> This means that all of the "if( MINGW )" tests and the like in
> CMakeModules/download_openssl.cmake go away and we end up with a common build system for
> all systems. It should work for all systems.
> 
> Hopefully we can use this build system instead of the horrible PERL one. It's probably not
> the most complete build system in the world - but it appears to do the job admirably. I
> tried "openssl speed" to stress test the library build with the CMake build system and
> everything looked good.
> 
> I need to test it on Linux, and I don't have a MAC box to test on, but I can't see
> anything that shouldn't work - everything's pretty generic.
> 
> It's a shame launchpad release file URL's are so verbose - I didn't bother trying to put
> the version number variable in it, it's probably easier to just change that URL when the
> MD5 and version variables are changed.
> 
> Dick, does this look good to you? 

Brian,

If it works for you, it works for me.  I want your life as easy as possible!  Plus if it
works for you, it works for Windows users, and that brings them use of the GITHUB_PLUGIN,
so I am happy all around.

IMO, it is also good for openssl.  But you know how folks are with their build systems.
(Folks like sticking with what they know.)

Some comments:

a) pcbnew/github/CMakeLists.txt will continue to use find_package( OpenSSL REQUIRED ) on
linux.  This is the path of least resistance for that platform.

b) The path chosen on OSX seems unclear to me, but as written, github/CMakeLists.txt will
route OSX builders to find_package() as well, meaning they will have to install openssl in
advance of the build.  I don't know OSX, the possibility to use your openssl build system
is on the table, but just guessing, it seems they will prefer a pre-built package like on
linux.

c) You commented out the toolchain statement.  I know Orson and others are cross building
the entire KiCad for Windows on Linux.  To me it seems we need to pass the
CMAKE_TOOLCHAIN_FILE setting in, on the assumption that if it is blank, it won't break the
native build.  You will confirm that upon re-enabling it.

d) Seems to need another new line at end of file, see very bottom.


> It builds on the excellent work you did on downloading
> and building openssl, 

I was passing the baton, knowing and hoping you'd step in and make it work for the most
difficult platform.  Trying to save you some initial work.

You continue to be an MVP.

Dick



but it also wipes out quite a bit of work you'd already done. This
> does mean we are in control of the build in the same way on all platforms though, and of
> course, it's a CMake build system too!
> 
> I will try to contact the OpenSSL guys and see if they are in any way keen to have a CMake
> build system contribution.
> 
> Best Regards,
> 
> Brian.
> 
> openssl-cmake-kicad.diff
> 
> 
> === modified file 'CMakeModules/download_openssl.cmake'
> --- CMakeModules/download_openssl.cmake	2013-09-22 03:24:11 +0000
> +++ CMakeModules/download_openssl.cmake	2013-10-22 21:20:53 +0000
> @@ -29,60 +29,19 @@
>  #-----<configure>-------------------------------------------------------------------------------------
>  
>  set( OPENSSL_RELEASE "1.0.1e" )
> -set( OPENSSL_MD5 66bf6f10f060d561929de96f9dfe5b8c ) # re-calc on every RELEASE change
> +set( OPENSSL_MD5 08bec482fe1c4795e819bfcfcb9647b9 ) # re-calc on every RELEASE change
>  
>  #-----</configure>-----------------------------------------------------------------------------------
>  
> -unset( PIC_FLAG )
> -set( CFLAGS CFLAGS=${CMAKE_C_FLAGS} )
> -
> -if( MINGW )         # either MINGW or cross compiling?
> -    if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
> -        set( MINGW32 true )
> -        set( MACHINE x86_32 )
> -    elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
> -        set( MINGW64 true )
> -        set( MACHINE x86_64 )
> -    endif()
> -
> -    if( MINGW32 )
> -        set( HOST "--host=i586-pc-mingw32" )
> -    elseif( MINGW64 )
> -        set( HOST "--host=x86_64-pc-mingw32" )
> -    endif()
> -
> -    set( CC "CC=${CMAKE_C_COMPILER}" )
> -    set( RANLIB "RANLIB=${CMAKE_RANLIB}" )
> -    set( AR "AR=${CMAKE_AR}" )
> -else()
> -    set( PIC_FLAG -fPIC )
> -endif()
> -
> -string( TOLOWER ${CMAKE_HOST_SYSTEM_NAME} build )
> -
> -# Force some configure scripts into knowing this is a cross-compilation, if it is.
> -set( BUILD --build=${CMAKE_HOST_SYSTEM_PROCESSOR}-pc-${build} )
> -
> -
> -# http://www.blogcompiler.com/2011/12/21/openssl-for-windows/
> -# http://qt-project.org/wiki/Compiling-OpenSSL-with-MinGW
>  set( PREFIX ${DOWNLOAD_DIR}/openssl-${OPENSSL_RELEASE} )
>  
> -unset( CROSS )
> -if( MINGW32 )
> -    set( MW mingw )
> -    set( CROSS "CROSS_COMPILE=${CROSS_COMPILE}" )
> -elseif( MINGW64 )
> -    set( MW mingw64 )
> -    set( CROSS "CROSS_COMPILE=${CROSS_COMPILE}" )
> -endif()
> -
>  ExternalProject_Add(
>      openssl
>      DOWNLOAD_DIR ${DOWNLOAD_DIR}
>      PREFIX ${PREFIX}
>      TIMEOUT 60
> -    URL http://www.openssl.org/source/openssl-${OPENSSL_RELEASE}.tar.gz
> +    URL http://launchpad.net/openssl-cmake/1.0.1e/1.0.1e-1/+download/openssl-cmake-1.0.1e-src.tar.gz
> +    #URL http://www.valvers.com/files/openssl-cmake-1.0.1e-src.tar.gz
>      URL_MD5 ${OPENSSL_MD5}
>  
>      # mingw uses msvcrt.dll's printf() which cannot handle %zd, so having
> @@ -97,17 +56,17 @@
>  
>      # this requires that perl be installed:
>      CONFIGURE_COMMAND
> -            ${CROSS}
> -            <SOURCE_DIR>/Configure
> -            ${MW}
> -            --prefix=<INSTALL_DIR>
> -            ${PIC_FLAG}         # empty for MINGW
> -            shared
> +            ${CMAKE_COMMAND}
> +            -G ${CMAKE_GENERATOR}
> +            -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
> +            -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
> +            -DBUILD_SHARED_LIBS=ON
> +            #-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
> +            <SOURCE_DIR>
>  
>      BUILD_IN_SOURCE 1
> -    BUILD_COMMAND make depend
> -          COMMAND make
> -    INSTALL_COMMAND make install
> +    BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
> +    INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
>      )
>  
>  # In order to use "bzr patch", we have to have a bzr working tree, this means a bzr repo
> @@ -141,8 +100,8 @@
>      )
>  
>  set( OPENSSL_LIBRARIES
> -    ${PREFIX}/lib/libssl.a
> -    ${PREFIX}/lib/libcrypto.a
> +    ${PREFIX}/lib/libssl${CMAKE_IMPORT_LIBRARY_SUFFIX}
> +    ${PREFIX}/lib/libcrypto${CMAKE_IMPORT_LIBRARY_SUFFIX}
>      CACHE STRING "OPENSSL libraries"
>      )
>  set( OPENSSL_FOUND true )
> 
> === modified file 'pcbnew/github/CMakeLists.txt'
> --- pcbnew/github/CMakeLists.txt	2013-10-13 21:33:58 +0000
> +++ pcbnew/github/CMakeLists.txt	2013-10-20 20:52:04 +0000
> @@ -73,3 +73,7 @@
>  
>  add_dependencies( github_plugin boost )
>  add_dependencies( github_plugin avhttp )
> +
> +if( MINGW AND NOT OPENSSL_ROOT_DIR )
> +    add_dependencies( github_plugin openssl )
> +endif()
> \ No newline at end of file
> 
> 
> 
> _______________________________________________
> 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