THRIFT-2850 CMake: improve Windows support
use YY_NO_UNISTD_H and remove --wincompat
diff --git a/build/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake
index 515bb18..db411d5 100644
--- a/build/cmake/DefinePlatformSpecifc.cmake
+++ b/build/cmake/DefinePlatformSpecifc.cmake
@@ -65,7 +65,7 @@
# Windows build does not know how to make a shared library yet
# as there are no __declspec(dllexport) or exports files in the project.
if (WITH_SHARED_LIB)
- message (FATAL_ERROR "Windows build does not support shared library output yet!")
+ message (FATAL_ERROR "Windows build does not support shared library output yet, please set -DWITH_SHARED_LIB=off")
endif()
elseif(UNIX)
diff --git a/compiler/cpp/CMakeLists.txt b/compiler/cpp/CMakeLists.txt
index 5642d16..01e229d 100644
--- a/compiler/cpp/CMakeLists.txt
+++ b/compiler/cpp/CMakeLists.txt
@@ -19,10 +19,8 @@
# Windows has a different header
if(MSVC)
- set(FLEX_FLAGS "--wincompat") # Don't use unistd.h on windows
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/windows/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
else()
- set(FLEX_FLAGS " ")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
endif()
@@ -31,7 +29,7 @@
# Create flex and bison files and build the lib parse static library
BISON_TARGET(thrifty ${CMAKE_CURRENT_SOURCE_DIR}/src/thrifty.yy ${CMAKE_CURRENT_BINARY_DIR}/thrifty.cc)
-FLEX_TARGET(thriftl ${CMAKE_CURRENT_SOURCE_DIR}/src/thriftl.ll ${CMAKE_CURRENT_BINARY_DIR}/thriftl.cc COMPILE_FLAGS ${FLEX_FLAGS})
+FLEX_TARGET(thriftl ${CMAKE_CURRENT_SOURCE_DIR}/src/thriftl.ll ${CMAKE_CURRENT_BINARY_DIR}/thriftl.cc)
ADD_FLEX_BISON_DEPENDENCY(thriftl thrifty)
# HACK: Work around the fact that bison crates a .hh file but we need a .h file
diff --git a/compiler/cpp/README.md b/compiler/cpp/README.md
index fdc6451..b4a159f 100644
--- a/compiler/cpp/README.md
+++ b/compiler/cpp/README.md
@@ -25,24 +25,27 @@
## Build on windows
-In order to build on windows a few additional steps are necessary:
+### using Git Bash
+Git Bash provides flex and bison, so you just need to do this:
+
+ mkdir build_vs && cd build_vs
+ cmake -DWITH_SHARED_LIB=off ..
+
+### using Win flex-bison
+
+In order to build on windows with winflexbison a few additional steps are necessary:
1. Download winflexbison from http://sourceforge.net/projects/winflexbison/
2. Extract the winflex bison files to for e.g. C:\winflexbison
3. Make the CMake variables point to the correct binaries.
* FLEX_EXECUTABLE = C:/winbuild/win_flex.exe
* BISON_EXECUTABLE = C:/winbuild/win_bison.exe
-
-
-### Create a Visual Studio project
-
- mkdir build_vs && cd build_vs
- cmake -G "Visual Studio 12" ..
-
-Now open the folder build_vs using Visual Studio 2013.
-
-
-
+4. Generate a Visual Studio project:
+```
+mkdir build_vs && cd build_vs
+cmake -G "Visual Studio 12" -DWITH_SHARED_LIB=off ..
+```
+5. Now open the folder build_vs using Visual Studio 2013.
# Building the Thrift IDL compiler in Windows
diff --git a/compiler/cpp/src/thriftl.ll b/compiler/cpp/src/thriftl.ll
index a8ffe57..11ba1b9 100644
--- a/compiler/cpp/src/thriftl.ll
+++ b/compiler/cpp/src/thriftl.ll
@@ -43,6 +43,8 @@
#pragma warning(disable:4102)
//avoid isatty redefinition
#define YY_NEVER_INTERACTIVE 1
+
+#define YY_NO_UNISTD_H 1
#endif
#include <cassert>