README-MSYS2.md
1<!---
2Licensed under the Apache License, Version 2.0 (the "License");
3you may not use this file except in compliance with the License.
4You may obtain a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8Unless required by applicable law or agreed to in writing, software
9distributed under the License is distributed on an "AS IS" BASIS,
10WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11See the License for the specific language governing permissions and
12limitations under the License.
13-->
14
15# Building thrift on Windows (MinGW64/MSYS2)
16
17Thrift uses cmake to make it easier to build the project on multiple platforms, however to build a fully functional and production ready thrift on Windows requires a number of third party libraries to be obtained. Once third party libraries are ready, the right combination of options must be passed to cmake in order to generate the correct environment.
18
19> Note: libevent and libevent-devel do not work with this toolchain as they do not properly detect mingw64 and expect some headers to exist that do not, so the non-blocking server is not currently built into this solution.
20
21## MSYS2
22
23Download and fully upgrade msys2 following the instructions at:
24
25 https://msys2.github.io/
26
27Install the necessary toolchain items for C++:
28
29 $ pacman --needed -S bison flex make mingw-w64-x86_64-openssl \
30 mingw-w64-x86_64-boost mingw-w64-x86_64-cmake \
31 mingw-w64-x86_64-toolchain mingw-w64-x86_64-zlib
32
33Update your msys2 bash path to include /mingw64/bin by adding a line to your ~/.bash_profiles using this command:
34
35 echo "export PATH=/mingw64/bin:\$PATH" >> ~/.bash_profile
36
37After that, close your shell and open a new one.
38
39Use cmake to create a MinGW makefile, out of tree (assumes you are in the top level of the thrift source tree):
40
41 mkdir ../thrift-build
42 cd ../thrift-build
43 cmake -G"MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=/mingw64/bin/mingw32-make \
44 -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc.exe \
45 -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++.exe \
46 -DWITH_LIBEVENT=OFF \
47 -DWITH_SHARED_LIB=OFF -DWITH_STATIC_LIB=ON \
48 -DWITH_JAVA=OFF -DWITH_PYTHON=OFF -DWITH_PERL=OFF \
49 ../thrift
50
51Build thrift (inside thrift-build):
52
53 cmake --build .
54
55Run the tests (inside thrift-build):
56
57 ctest
58
59> If you run into issues, check Apache Jira THRIFT-4046 for patches relating to MinGW64/MSYS2 builds.
60
61## Tested With
62
63msys2 64-bit 2016-10-26 distribution
64
README.md
1# Apache Thrift - CMake Build
2
3## Goal
4
5Extend Apache Thrift's *make cross* approach to the build system.
6
7Due to growing the field of operating system support, a proper executable
8and library detection mechanism running on as much platforms as possible
9becomes required. The other aspect to simplify the release process and
10package generation process.
11
12As nice side benefit of CMake is the generation of development environment
13specific soultion files. => No solution files within source tree.
14
15## Prerequisites
16
17These are language-specific, however for C++ you must provide:
18
19- Boost
20- OpenSSL
21
22You may optionally provide:
23
24- libevent
25- zlib
26
27## Usage
28
29To use CMake you first create an out-of-tree build directory, then use
30CMake to generate a build framework, then build:
31
32 mkdir /tmp/build
33 cd /tmp/build
34 cmake /location/to/thrift
35
36if you use a specific toolchain pass it to cmake, the same for options:
37
38 cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake ..
39 cmake -DCMAKE_C_COMPILER=clang-3.5 -DCMAKE_CXX_COMPILER=clang++-3.5 ..
40 cmake -DTHRIFT_COMPILER_HS=OFF ..
41 cmake -DWITH_ZLIB=ON ..
42
43and open the development environment you like with the solution or do this:
44
45 make
46 make check
47 make cross
48 make dist
49
50or on Windows, the following will produce a solution file you can use
51inside Visual Studio:
52
53 cmake -G "Visual Studio 15 2017 Win64" \
54 -DBOOST_ROOT=C:/3rdparty/boost_1_69_0 \
55 -DBOOST_LIBRARYDIR=C:/3rdparty/boost_1_69_0/lib64-msvc-14.1^
56 -DZLIB_ROOT=C:/3rdparty/zlib-1.2.11
57
58<!--
59To generate an installer and distribution package do this:
60
61 cpack
62-->
63
64## TODO
65
66* git hash or tag based versioning depending on source state
67* build tutorial
68* build test
69* enable/disable
70* make cross
71* make dist (create an alias to make package_source)
72* make doc
73* cpack (C++ and make dist only ?)
74 * thrift-compiler
75 * libthrift
76 * tutorial
77 * test
78* merge into /README.md