summaryrefslogtreecommitdiff
path: root/infrastructure/cmake/windows/CMakeLists.txt
blob: 80d1369b2633ea7d9bcb5b74bc2b47ab44427c82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
cmake_minimum_required(VERSION 2.6)

project(BoxBackup_Windows)

set(boxbackup_dir ${CMAKE_SOURCE_DIR}/../../..)
set_property(DIRECTORY PROPERTY EP_BASE .)
set(install_dir ${CMAKE_BINARY_DIR}/install)

# Automate the process of downloading, building and "installing" dependencies on Windows,
# as used by AppVeyor.

# Version of zlib to download, build, and compile Box Backup against:
set(ZLIB_VERSION    1.2.11)
# Hash of zlib-${ZLIB_VERSION}.tar.gz, to be verified after download:
set(ZLIB_HASH SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1)

# Version of OpenSSL to download, build, and compile Box Backup against:
set(OPENSSL_VERSION 1.0.2j)
# Hash of openssl-${OPENSSL_VERSION}.tar.gz, to be verified after download:
set(OPENSSL_HASH SHA256=e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431)

# Version of PCRE to download, build, and compile Box Backup against:
set(PCRE_VERSION    8.39)
# Hash of pcre-${PCRE_VERSION}.tar.gz, to be verified after download:
set(PCRE_HASH SHA256=ccdf7e788769838f8285b3ee672ed573358202305ee361cfec7a4a4fb005bbc7)

# Version of Boost to download, unpack, and compile Box Backup against:
set(BOOST_VERSION    1.62.0)
# Hash of the Boost download file, to be verified after download:
set(BOOST_HASH SHA1=5fd97433c3f859d8cbab1eaed4156d3068ae3648)

include(ExternalProject)

ExternalProject_Add(zlib
	URL "http://zlib.net/zlib-${ZLIB_VERSION}.tar.gz"
	URL_HASH ${ZLIB_HASH}
	DOWNLOAD_NO_PROGRESS 1
	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${install_dir} ${SUB_CMAKE_EXTRA_ARGS}
	# 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
	# Temporarily use SVN repo until the PCRE_STATIC issue in 8.40 is fixed:
	# https://vcs.pcre.org/pcre?view=revision&revision=1677
	SVN_REPOSITORY svn://vcs.exim.org/pcre/code/trunk
	SVN_REVISION -r 1677
	DOWNLOAD_NO_PROGRESS 1
	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${install_dir} ${SUB_CMAKE_EXTRA_ARGS}
	-DPCRE_SUPPORT_LIBREADLINE=OFF
	-DPCRE_SUPPORT_LIBBZ2=OFF
	# 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
)

string(REPLACE "." "_" BOOST_VERSION_UNDERSCORES ${BOOST_VERSION})
ExternalProject_Add(boost
	URL "http://downloads.sourceforge.net/project/boost/boost/${BOOST_VERSION}/boost_${BOOST_VERSION_UNDERSCORES}.tar.bz2"
	URL_HASH ${BOOST_HASH}
	# DOWNLOAD_NO_PROGRESS 1
	CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "No configure step needed"
	BUILD_COMMAND ${CMAKE_COMMAND} -E echo "No build step needed"
	INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "No install step needed"
)

if(BOXBACKUP_VERSION)
	list(APPEND boxbackup_cmake_args "-DBOXBACKUP_VERSION=${BOXBACKUP_VERSION}")
endif()
string(REPLACE ";" " " boxbackup_cmake_args "${boxbackup_cmake_args}")

ExternalProject_Add(boxbackup
	DEPENDS zlib openssl pcre boost
	SOURCE_DIR ${boxbackup_dir}/infrastructure/cmake
	CMAKE_ARGS
		-DZLIB_ROOT=${install_dir}
		-DOPENSSL_ROOT_DIR=${install_dir}
		-DPCRE_ROOT=${install_dir}
		-DBOOST_ROOT=${CMAKE_BINARY_DIR}/Source/boost
		-DBOX_SUPPORT_READLINE=OFF
		-DCMAKE_INSTALL_PREFIX=${install_dir}
		-DAPPVEYOR_MODE=1
		-DDEBUG=${DEBUG}
		${boxbackup_cmake_args}
		${SUB_CMAKE_EXTRA_ARGS}
	STEP_TARGETS configure build install
)