1 # Build Thrift IDL compiler using CMake
5 - [Build Thrift IDL compiler using CMake](#build-thrift-idl-compiler-using-cmake)
6 - [Build on Unix-like System](#build-on-unix-like-system)
7 - [Prerequisites](#prerequisites)
8 - [Build using CMake](#build-using-cmake)
9 - [Build with Eclipse IDE](#build-with-eclipse-ide)
10 - [Build with XCode IDE in MacOS](#build-with-xcode-ide-in-macos)
11 - [Usage of other IDEs](#usage-of-other-ides)
12 - [Build on Windows](#build-on-windows)
13 - [Prerequisites](#prerequisites-1)
14 - [Build using Git Bash](#build-using-git-bash)
15 - [Using Visual Studio and Win flex-bison](#using-visual-studio-and-win-flex-bison)
16 - [Cross compile using mingw32 and generate a Windows Installer with CPack](#cross-compile-using-mingw32-and-generate-a-windows-installer-with-cpack)
17 - [Other cases](#other-cases)
18 - [Building the Thrift IDL compiler in Windows without CMake](#building-the-thrift-idl-compiler-in-windows-without-cmake)
19 - [Unit tests for compiler](#unit-tests-for-compiler)
20 - [Using boost test](#using-boost-test)
21 - [Using Catch C++ test library](#using-catch-c-test-library)
22 - [Have a Happy free time and holidays](#have-a-happy-free-time-and-holidays)
26 ## Build on Unix-like System
30 - Install flex and bison
34 - Go to **thrift\compiler\cpp**
35 - Use the following steps to build using cmake:
38 mkdir cmake-build && cd cmake-build
43 #### Build with Eclipse IDE
45 - Go to **thrift\compiler\cpp**
46 - Use the following steps to build using cmake:
49 mkdir cmake-ec && cd cmake-ec
50 cmake -G "Eclipse CDT4 - Unix Makefiles" ..
54 Now open the folder cmake-ec using eclipse.
56 #### Build with XCode IDE in MacOS
58 - Install/update flex, bison and cmake with brew
65 - Go to **thrift\compiler\cpp**
66 - Run commands in command line:
69 mkdir cmake-build && cd cmake-build
74 #### Usage of other IDEs
76 Please check list of supported IDE
85 - Install CMake - https://cmake.org/download/
86 - In case if you want to build without Git Bash - install winflexbison - https://sourceforge.net/projects/winflexbison/
87 - In case if you want to build with Visual Studio - install Visual Studio
88 - Better to use the latest stable Visual Studio Community Edition - https://www.visualstudio.com/vs/whatsnew/ (ensure that you installed workload "Desktop Development with C++" for VS2017) - Microsoft added some support for CMake and improving it in Visual Studio
90 ### Build using Git Bash
92 Git Bash provides flex and bison
94 - Go to **thrift\compiler\cpp**
95 - Use the following steps to build using cmake:
98 mkdir cmake-vs && cd cmake-vs
99 cmake -DWITH_SHARED_LIB=off ..
103 ### Using Visual Studio and Win flex-bison
105 - Generate a Visual Studio project for version of Visual Studio which you have (**cmake --help** can show list of supportable VS versions):
106 - Run commands in command line:
110 cmake -G "Visual Studio 15 2017" ..
112 - Now open the folder cmake-vs using Visual Studio.
114 ### Cross compile using mingw32 and generate a Windows Installer with CPack
117 mkdir cmake-mingw32 && cd cmake-mingw32
118 cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF ..
124 ## Building the Thrift IDL compiler in Windows without CMake
126 If you don't want to use CMake you can use the already available Visual Studio 2010 solution.
128 The Visual Studio project contains pre-build commands to generate the thriftl.cc, thrifty.cc and thrifty.hh files which are necessary to build the compiler.
130 These depend on bison, flex and their dependencies to work properly.
132 Download flex & bison as described above.
134 Place these binaries somewhere in the path and rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively.
136 If this doesn't work on a system, try these manual pre-build steps.
138 Open compiler.sln and remove the Pre-build commands under the project's: Properties -> Build Events -> Pre-Build Events.
140 From a command prompt:
142 cd thrift/compiler/cpp
143 flex -o src\thrift\thriftl.cc src\thrift\thriftl.ll
145 In the generated thriftl.cc, comment out #include <unistd.h>
147 Place a copy of bison.simple in thrift/compiler/cpp
149 bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy
150 move src\thrift\thrifty.cc.hh src\thrift\thrifty.hh
153 Bison 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".
156 move src\thrift\version.h.in src\thrift\version.h
159 Download inttypes.h from the interwebs and place it in an include path
160 location (e.g. thrift/compiler/cpp/src).
162 Build the compiler in Visual Studio.
164 # Unit tests for compiler
167 - pls check **test** folder
169 ## Using Catch C++ test library
171 Added generic way to cover code by tests for many languages (you just need to make a correct header file for generator for your language - example in **netcore** implementation)
173 - pls check **tests** folder
175 # Have a Happy free time and holidays