diff options
author | Chris Wilson <chris+github@qwirx.com> | 2016-09-07 22:34:37 +0100 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2016-09-09 20:54:18 +0100 |
commit | 4c34bf6cd51e3ebe5a6ac21cbdae6b90d9def78e (patch) | |
tree | 83af42132bf47bbcc25c262d19cef3e81aeeeea9 | |
parent | 26495a510a2533619ce68d6e3b48026c5b76d1d1 (diff) |
Replace most of Appveyor Windows build script with a CMakefile.
Should make it easier for Windows developers to get started by automating
almost everything.
-rw-r--r-- | appveyor.yml | 69 | ||||
-rw-r--r-- | infrastructure/cmake/windows/CMakeLists.txt | 89 |
2 files changed, 104 insertions, 54 deletions
diff --git a/appveyor.yml b/appveyor.yml index 2d6f5558..1def8a7a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -40,12 +40,11 @@ init: build: parallel: true - project: infrastructure/cmake/build/INSTALL.vcxproj + project: ..\cmake\BoxBackup_Windows.sln + verbosity: quiet install: - # Show compiled files restored from cache - - dir %APPVEYOR_BUILD_FOLDER%\infrastructure\cmake\build - # test_bbackupd needs 7zip to extract tar archives on Windows: + # test_bbackupd needs 7zip (or cmake -E tar) to extract tar archives on Windows: - cinst -y --limit-output 7zip.commandline # Install cmake.portable instead of cmake, to get it on the path again: # http://disq.us/p/xdknrt @@ -57,59 +56,21 @@ install: # cinst -y cmake strawberryperl git vim visualstudio2012wdx - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x86' - - - cd %APPVEYOR_BUILD_FOLDER%\.. - - if not exist zlib128.zip appveyor DownloadFile "http://zlib.net/zlib128.zip" - - 7za x -aoa zlib128.zip - - cd zlib-1.2.8 - - cmake -G "%Generator%" -A %PLATFORM% -DCMAKE_INSTALL_PREFIX="..\zlib-%PLATFORM%" . - # We need to build both versions, debug and release, because cmake requires both to be - # present to generate its multi-configuration project files for Visual Studio/MSBuild. - - msbuild INSTALL.vcxproj /m /p:Configuration=Debug /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild INSTALL.vcxproj /m /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - - cd %APPVEYOR_BUILD_FOLDER%\.. - - if not exist openssl-%OPENSSL_VERSION%.tar.gz appveyor DownloadFile "https://www.openssl.org/source/openssl-%OPENSSL_VERSION%.tar.gz" - - 7za x -aoa openssl-%OPENSSL_VERSION%.tar.gz - - 7za x -aoa openssl-%OPENSSL_VERSION%.tar - - cd openssl-%OPENSSL_VERSION% - - perl Configure debug-VC-WIN32 no-asm --prefix="%APPVEYOR_BUILD_FOLDER%\..\openssl-%PLATFORM%" - - ms\do_ms - - nmake /s /f ms\nt.mak - - nmake /s /f ms\nt.mak install - - - cd %APPVEYOR_BUILD_FOLDER%\.. - - if not exist pcre-%PCRE_VERSION%.zip appveyor DownloadFile "http://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-%PCRE_VERSION%.zip" - - 7za x -aoa pcre-%PCRE_VERSION%.zip - cd %APPVEYOR_BUILD_FOLDER%\.. - - cd pcre-%PCRE_VERSION% - - cmake -G "%Generator%" -A %PLATFORM% -DCMAKE_INSTALL_PREFIX="..\pcre-%PLATFORM%" . - - dir - # We need to build both versions, debug and release, because cmake requires both to be - # present to generate its multi-configuration project files for Visual Studio/MSBuild. - - msbuild INSTALL.vcxproj /m /p:Configuration=Debug /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - msbuild INSTALL.vcxproj /m /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - cd %APPVEYOR_BUILD_FOLDER%\.. - - dir - - dir pcre-%PLATFORM% - - dir pcre-%PLATFORM%\bin - - dir pcre-%PLATFORM%\lib - - - cd %APPVEYOR_BUILD_FOLDER% - - cd infrastructure\cmake\build - - cmake -G "%Generator%" -A %PLATFORM% -DZLIB_ROOT=%APPVEYOR_BUILD_FOLDER%\..\zlib-%PLATFORM% -DOPENSSL_ROOT_DIR=%APPVEYOR_BUILD_FOLDER%\..\openssl-%PLATFORM% -DPCRE_ROOT=%APPVEYOR_BUILD_FOLDER%\..\pcre-%PLATFORM% .. - - cd %APPVEYOR_BUILD_FOLDER% + - if not exist cmake md cmake + - cd cmake + # We need to specify the generator here, in case the user has more than one installed. + # CMake always seems to default to the latest version of Visual Studio, not the one on + # the current PATH. + - cmake -G "%Generator%" -A %PLATFORM% %APPVEYOR_BUILD_FOLDER%\infrastructure\cmake\windows - # Show files after build - - dir %APPVEYOR_BUILD_FOLDER%\..\zlib-1.2.8 - - dir %APPVEYOR_BUILD_FOLDER%\..\zlib-%PLATFORM% - - dir %APPVEYOR_BUILD_FOLDER%\..\openssl-%OPENSSL_VERSION% - - dir %APPVEYOR_BUILD_FOLDER%\..\openssl-%PLATFORM% - - dir %APPVEYOR_BUILD_FOLDER%\..\pcre-%PCRE_VERSION% - - dir %APPVEYOR_BUILD_FOLDER%\..\pcre-%PLATFORM% - - dir %APPVEYOR_BUILD_FOLDER%\infrastructure\cmake\build + # Leave the current directory in the correct place to find the solution file using its relative path above. test_script: - - cd %APPVEYOR_BUILD_FOLDER%\infrastructure\cmake\build + - cd %APPVEYOR_BUILD_FOLDER%\..\cmake\src\boxbackup-build + # - dir + # - dir bin_bbackupd.dir + # - dir %PLATFORM% + # - dir %PLATFORM%\%CONFIGURATION% - ctest -C %CONFIGURATION% -V diff --git a/infrastructure/cmake/windows/CMakeLists.txt b/infrastructure/cmake/windows/CMakeLists.txt new file mode 100644 index 00000000..42152714 --- /dev/null +++ b/infrastructure/cmake/windows/CMakeLists.txt @@ -0,0 +1,89 @@ +cmake_minimum_required(VERSION 2.6) + +project(BoxBackup_Windows) + +set(boxbackup_dir ${CMAKE_SOURCE_DIR}/../../..) +set_property(DIRECTORY PROPERTY EP_PREFIX .) +set(install_dir ${CMAKE_BINARY_DIR}/install) + +# Automate the process of downloading, building and "installing" dependencies on Windows, +# as used by AppVeyor. +set(ZLIB_VERSION 1.2.8 CACHE STRING "Version of zlib to download, build, and compile Box Backup against") +set(ZLIB_HASH MD5=126f8676442ffbd97884eb4d6f32afb4 + CACHE STRING "Hash of the zlib download file, to be verified after download") +set(OPENSSL_VERSION 1.0.2h CACHE STRING "Version of OpenSSL to download, build, and compile Box Backup against") +set(OPENSSL_HASH SHA256=1d4007e53aad94a5b2002fe045ee7bb0b3d98f1a47f8b2bc851dcd1c74332919 + CACHE STRING "Hash of the OpenSSL download file, to be verified after download") +set(PCRE_VERSION 8.38 CACHE STRING "Version of PCRE to download, build, and compile Box Backup against") +set(OPENSSL_HASH SHA256=dbef7cf80258c29396d435804cd5dba34006a77548850bca8bad6db6a6eac110 + CACHE STRING "Hash of the PCRE download file, to be verified after download") + +include(ExternalProject) + +string(REPLACE "." "" zlib_version_nodots ${ZLIB_VERSION}) +ExternalProject_Add(zlib + URL "http://zlib.net/zlib${zlib_version_nodots}.zip" + URL_HASH ${ZLIB_HASH} + DOWNLOAD_NO_PROGRESS 1 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${install_dir} + # We need to build both versions, debug and release, because cmake requires both to be + # present to generate its multi-configuration project files for Visual Studio/MSBuild. + INSTALL_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target install --config Debug + COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target install --config Release + STEP_TARGETS configure install +) + +if(WIN32) + ExternalProject_Add(openssl + DEPENDS zlib + URL "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" + URL_HASH ${OPENSSL_HASH} + DOWNLOAD_NO_PROGRESS 1 + CONFIGURE_COMMAND perl Configure debug-VC-WIN32 no-asm --prefix=${install_dir} + COMMAND cmd /c ms\\do_ms.bat + # You would expect us to use nt.mak to compile a static library here, but mk1mf.pl uses the /MT[d] + # CRT in that case, which is incompatible with our dynamic runtime, /MD[d]. It seems that the libs + # built by ntdll.mak, which are compiled with /MD[d], are full libraries and not import libs, + # so we can link statically against them and still get a dynamic runtime. + BUILD_IN_SOURCE 1 + BUILD_COMMAND nmake /s /f ms\\nt.mak + INSTALL_COMMAND nmake /s /f ms\\nt.mak install + ) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + ExternalProject_Add(openssl + DEPENDS zlib + URL "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" + URL_HASH ${OPENSSL_HASH} + DOWNLOAD_NO_PROGRESS 1 + CONFIGURE_COMMAND perl Configure darwin64-x86_64-cc --prefix=${install_dir} + BUILD_IN_SOURCE 1 + ) +else() + ExternalProject_Add(openssl + DEPENDS zlib + URL "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" + URL_HASH ${OPENSSL_HASH} + DOWNLOAD_NO_PROGRESS 1 + CONFIGURE_COMMAND ./config --prefix=${install_dir} + BUILD_IN_SOURCE 1 + ) + +endif() + +ExternalProject_Add(pcre + URL "http://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-${PCRE_VERSION}.zip" + URL_HASH ${PCRE_HASH} + DOWNLOAD_NO_PROGRESS 1 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${install_dir} + # We need to build both versions, debug and release, because cmake requires both to be + # present to generate its multi-configuration project files for Visual Studio/MSBuild. + INSTALL_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target install --config Debug + COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target install --config Release +) + +ExternalProject_Add(boxbackup + DEPENDS zlib openssl pcre + SOURCE_DIR ${boxbackup_dir}/infrastructure/cmake + CMAKE_ARGS -DZLIB_ROOT=${install_dir} -DOPENSSL_ROOT_DIR=${install_dir} -DPCRE_ROOT=${install_dir} -DAPPVEYOR_MODE=1 + STEP_TARGETS configure build install +) |