blob: ea195c717938778a7d57f7acfdd9d59f4c88c66e [file] [log] [blame] [view]
Pascal Bach6eb015a2014-04-17 16:19:07 +02001# Build compiler using CMake
2
henrique55087a42014-06-17 12:36:39 +02003Use the following steps to build using cmake:
Pascal Bach6eb015a2014-04-17 16:19:07 +02004
Roger Meier880a2b32015-05-16 22:40:17 +02005 mkdir cmake-build
6 cd cmake-build
Roger Meier746952e2014-06-14 21:59:24 +02007 cmake ..
8 make
Pascal Bach6eb015a2014-04-17 16:19:07 +02009
henrique55087a42014-06-17 12:36:39 +020010
11### Create an eclipse project
12
Roger Meier880a2b32015-05-16 22:40:17 +020013 mkdir cmake-ec && cd cmake-ec
henrique55087a42014-06-17 12:36:39 +020014 cmake -G "Eclipse CDT4 - Unix Makefiles" ..
15 make
16
Roger Meier880a2b32015-05-16 22:40:17 +020017Now open the folder cmake-ec using eclipse.
henrique55087a42014-06-17 12:36:39 +020018
19
Roger Meier311f7152014-08-17 22:24:30 +020020### Cross compile using mingw32 and generate a Windows Installer with CPack
henrique55087a42014-06-17 12:36:39 +020021
Roger Meier880a2b32015-05-16 22:40:17 +020022 mkdir cmake-mingw32 && cd cmake-mingw32
23 cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF ..
Roger Meier87202602014-08-15 22:16:02 +020024 cpack
25
Pascal Bach6eb015a2014-04-17 16:19:07 +020026## Build on windows
27
Roger Meier86fded22015-05-15 12:01:38 +020028### using Git Bash
29Git Bash provides flex and bison, so you just need to do this:
30
Roger Meier880a2b32015-05-16 22:40:17 +020031 mkdir cmake-vs && cd cmake-vs
Roger Meier86fded22015-05-15 12:01:38 +020032 cmake -DWITH_SHARED_LIB=off ..
33
34### using Win flex-bison
35
36In order to build on windows with winflexbison a few additional steps are necessary:
Pascal Bach6eb015a2014-04-17 16:19:07 +020037
381. Download winflexbison from http://sourceforge.net/projects/winflexbison/
392. Extract the winflex bison files to for e.g. C:\winflexbison
403. Make the CMake variables point to the correct binaries.
Jens Geyer176c9262015-01-29 00:30:08 +010041 * FLEX_EXECUTABLE = C:/winbuild/win_flex.exe
42 * BISON_EXECUTABLE = C:/winbuild/win_bison.exe
Roger Meier86fded22015-05-15 12:01:38 +0200434. Generate a Visual Studio project:
44```
Roger Meier880a2b32015-05-16 22:40:17 +020045mkdir cmake-vs && cd cmake-vs
Roger Meier86fded22015-05-15 12:01:38 +020046cmake -G "Visual Studio 12" -DWITH_SHARED_LIB=off ..
47```
485. Now open the folder build_vs using Visual Studio 2013.
henrique55087a42014-06-17 12:36:39 +020049
Roger Meier746952e2014-06-14 21:59:24 +020050# Building the Thrift IDL compiler in Windows
51
henrique55087a42014-06-17 12:36:39 +020052If you don't want to use CMake you can use the already available Visual Studio
532010 solution.
Roger Meier746952e2014-06-14 21:59:24 +020054The Visual Studio project contains pre-build commands to generate the
55thriftl.cc, thrifty.cc and thrifty.hh files which are necessary to build
56the compiler. These depend on bison, flex and their dependencies to
57work properly. If this doesn't work on a system, try these manual
58pre-build steps.
59
60Open compiler.sln and remove the Pre-build commands under the project's
61 Properties -> Build Events -> Pre-Build Events.
62
63Download flex & bison from http://jaisantonyk.wordpress.com/2008/03/16/lex-and-yaccbison-in-windows/
64Download bison.simple in addition to bison.exe . This build of bison is easier to use
65than the one on sourceforge which has a myriad of dependencies.
66Place these binaries somewhere in the path.
67
68From a command prompt:
69> cd thrift/compiler/cpp
70> flex -osrc\thriftl.cc src\thriftl.ll
71In the generated thriftl.cc, comment out #include <unistd.h>
72
73Place a copy of bison.simple in thrift/compiler/cpp
74> bison -y -o "src/thrifty.cc" --defines src/thrifty.yy
75> move src\thrifty.cc.hh src\thrifty.hh
76
77Bison might generate the yacc header file "thrifty.cc.h" with just one h ".h" extension; in this case you'll have to rename to "thrifty.h".
78
79> move src\windows\version.h.in src\windows\version.h
80
81Download inttypes.h from the interwebs and place it in an include path
82location (e.g. thrift/compiler/cpp/src).
83
84Build the compiler in Visual Studio.