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_BOOSTTHREADS=ON -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
4Extend Apache Thrift's *make cross* approach to the build system.
5
6Due to growing the field of operating system support, a proper executable
7and library detection mechanism running on as much platforms as possible
8becomes required. The other aspect to simplify the release process and
9package generation process.
10
11As nice side benefit of CMake is the generation of development environment
12specific soultion files. => No solution files within source tree.
13
14
15## Usage
16just do this:
17
18 mkdir cmake-build && cd cmake-build
19 cmake ..
20
21if you use a specific toolchain pass it to cmake, the same for options:
22
23 cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake ..
24 cmake -DCMAKE_C_COMPILER=clang-3.5 -DCMAKE_CXX_COMPILER=clang++-3.5 ..
25 cmake -DTHRIFT_COMPILER_HS=OFF ..
26 cmake -DWITH_ZLIB=ON ..
27
28or on Windows
29
30 cmake -G "Visual Studio 12 2013 Win64" \
31 -DBOOST_ROOT=C:/3rdparty/boost_1_58_0 \
32 -DZLIB_ROOT=C:/3rdparty/zlib128-dll \
33 -DWITH_SHARED_LIB=off -DWITH_BOOSTTHREADS=ON ..
34
35and open the development environment you like with the solution or do this:
36
37 make
38 make check
39 make cross
40 make dist
41
42to generate an installer and distribution package do this:
43
44 cpack
45
46## TODO
47* git hash or tag based versioning depending on source state
48* build tutorial
49* build test
50* with/without language lib/<lang>/
51* enable/disable
52* make cross
53* make dist (create an alias to make package_source)
54* make doc
55* cpack (C++ and make dist only ?)
56 * thrift-compiler
57 * libthrift
58 * tutorial
59 * test
60* merge into /README.md
61