You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by he...@apache.org on 2014/06/11 09:29:21 UTC

[3/4] git commit: Allow cross build for windows using mingw32

Allow cross build for windows using mingw32

- Build the compiler using CMake for:
  - Linux native gcc
  - Windows using mingw32


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/569863a1
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/569863a1
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/569863a1

Branch: refs/heads/master
Commit: 569863a1385c38eb937662aa655db1c3fb0819fe
Parents: 42be4e8
Author: Pascal Bach <pa...@siemens.com>
Authored: Tue Jun 10 13:15:40 2014 +0200
Committer: Pascal Bach <pa...@siemens.com>
Committed: Tue Jun 10 13:44:02 2014 +0200

----------------------------------------------------------------------
 .travis.yml                     |  2 ++
 compiler/cpp/CMakeLists.txt     |  3 +--
 contrib/mingw32-toolchain.cmake | 19 +++++++++++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/569863a1/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 2ae6fcb..d40e81c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -72,5 +72,7 @@ script:
   - make -j$NUM_CPU && make dist
   - make cross -j$NUM_CPU
   - sh bootstrap.sh ; sh contrib/mingw-cross-compile.sh
+  - mkdir build_native && cd build_native && cmake ../compiler/cpp/ && make; cd ..
+  - mkdir build_mingw32 && cd build_mingw32 && cmake -DCMAKE_TOOLCHAIN_FILE=../contrib/mingw32-toolchain.cmake ../compiler/cpp/ && make; cd ..
 # TODO: add these steps
 #  - sh bootstrap.sh ; dpkg-buildpackage -tc

http://git-wip-us.apache.org/repos/asf/thrift/blob/569863a1/compiler/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/compiler/cpp/CMakeLists.txt b/compiler/cpp/CMakeLists.txt
index 5e07178..152e5db 100644
--- a/compiler/cpp/CMakeLists.txt
+++ b/compiler/cpp/CMakeLists.txt
@@ -37,7 +37,7 @@ string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" thrift_VERSION_PATCH ${t
 message(STATUS "Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
 
 # Windows has a different header
-if(WIN32)
+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()
@@ -144,7 +144,6 @@ THRIFT_ADD_COMPILER(lua     "Enable compiler for Lua" ON)
 include_directories(${CMAKE_CURRENT_BINARY_DIR} src)
 
 add_executable(thrift ${thrift_SOURCES})
-set_target_properties(thrift PROPERTIES VERSION ${thrift_VERSION})
 
 target_link_libraries(thrift libparse)
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/569863a1/contrib/mingw32-toolchain.cmake
----------------------------------------------------------------------
diff --git a/contrib/mingw32-toolchain.cmake b/contrib/mingw32-toolchain.cmake
new file mode 100644
index 0000000..3dfb1a5
--- /dev/null
+++ b/contrib/mingw32-toolchain.cmake
@@ -0,0 +1,19 @@
+# CMake mingw32 cross compile toolchain file
+
+# the name of the target operating system
+SET(CMAKE_SYSTEM_NAME Windows)
+
+# which compilers to use for C and C++
+SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
+SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
+SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
+
+# here is the target environment located
+SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search 
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)