summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Bach <pascal.bach@siemens.com>2014-12-12 15:59:17 +0100
committerRoger Meier <roger@apache.org>2014-12-13 22:02:29 +0100
commitd5f87e1f2135f51d6b9ab019f23891f3b1aeceec (patch)
tree48e0f0a6fb574e65053e3f4d61e642a6338d23b9
parenta195a2574ef9729da9be65283d29b87e39e8ebcb (diff)
downloadthrift-d5f87e1f2135f51d6b9ab019f23891f3b1aeceec.tar.gz
CMake: Add CMake support for Thrift libraries
Currently the following libraries are supported: - C++ - C_Glib - Java (using Ant wrapper) The compilers CMake file is adjusted to work with the new global CMakeLists.txt file. Signed-off-by: Roger Meier <r.meier@siemens.com> Signed-off-by: Pascal Bach <pascal.bach@siemens.com> Also-by: Sergei Nikulov <sergey.nikulov@gmail.com>
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt83
-rw-r--r--cmake/CPackConfig.cmake68
-rw-r--r--cmake/ConfigureChecks.cmake75
-rw-r--r--cmake/DefineCMakeDefaults.cmake58
-rw-r--r--cmake/DefineInstallationPaths.cmake26
-rw-r--r--cmake/DefineOptions.cmake102
-rw-r--r--cmake/DefinePlatformSpecifc.cmake65
-rw-r--r--cmake/FindAnt.cmake30
-rw-r--r--cmake/FindGLIB.cmake122
-rw-r--r--cmake/README.md54
-rw-r--r--cmake/ThriftMacros.cmake67
-rw-r--r--cmake/config.h.in157
-rw-r--r--compiler/cpp/CMakeLists.txt59
-rw-r--r--lib/c_glib/CMakeLists.txt69
-rw-r--r--lib/c_glib/test/CMakeLists.txt168
-rwxr-xr-xlib/cpp/CMakeLists.txt189
-rw-r--r--lib/cpp/test/CMakeLists.txt255
-rw-r--r--lib/java/CMakeLists.txt54
19 files changed, 1647 insertions, 55 deletions
diff --git a/.gitignore b/.gitignore
index 1651102bc..0b7d463ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -264,3 +264,4 @@ test-driver
/tutorial/js/build/
/ylwrap
+/cmake_*
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 000000000..712a5cac9
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,83 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+cmake_minimum_required(VERSION 2.8)
+
+project(thrift)
+
+set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+# TODO: add `git rev-parse --short HEAD`
+# Read the version information from the Autoconf file
+file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" CONFIGURE_AC REGEX "AC_INIT\\(.*\\)" )
+
+# The following variable is used in the version.h.in file
+string(REGEX REPLACE "AC_INIT\\(\\[.*\\], \\[([0-9]+\\.[0-9]+\\.[0-9]+(-dev)?)\\]\\)" "\\1" PACKAGE_VERSION ${CONFIGURE_AC})
+message(STATUS "Parsed Thrift package version: ${PACKAGE_VERSION}")
+
+# These are internal to CMake
+string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+)(-dev)?" "\\1" thrift_VERSION ${PACKAGE_VERSION})
+string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" thrift_VERSION_MAJOR ${thrift_VERSION})
+string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" thrift_VERSION_MINOR ${thrift_VERSION})
+string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" thrift_VERSION_PATCH ${thrift_VERSION})
+message(STATUS "Parsed Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
+
+# Some default settings
+include(DefineCMakeDefaults)
+
+# Build time options are defined here
+include(DefineOptions)
+include(DefineInstallationPaths)
+
+# Based on the options set some platform specifics
+include(DefinePlatformSpecifc)
+
+# Generate the config.h file
+include(ConfigureChecks)
+
+# Package it
+include(CPackConfig)
+
+
+find_package(Threads)
+
+include(CTest)
+if(BUILD_TESTING)
+ message(STATUS "Building with unittests")
+else ()
+ message(STATUS "Building without tests")
+endif ()
+if(BUILD_COMPILER)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp)
+endif()
+
+if(WITH_CPP)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
+endif()
+
+if(WITH_C_GLIB)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib)
+endif()
+
+if(WITH_JAVA)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/java)
+endif()
+
+PRINT_CONFIG_SUMMARY()
diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake
new file mode 100644
index 000000000..0941a8074
--- /dev/null
+++ b/cmake/CPackConfig.cmake
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+#TODO: Should we bundle system libraries for DLLs?
+#include(InstallRequiredSystemLibraries)
+
+# For help take a look at:
+# http://www.cmake.org/Wiki/CMake:CPackConfiguration
+
+### general settings
+set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
+set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Apache Thrift")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
+set(CPACK_PACKAGE_VENDOR "Apache Software Foundation")
+set(CPACK_PACKAGE_CONTACT "dev@thrift.apache.org")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
+set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
+
+### versions
+set(CPACK_PACKAGE_VERSION_MAJOR ${thrift_VERSION_MAJOR})
+set(CPACK_PACKAGE_VERSION_MINOR ${thrift_VERSION_MINOR})
+set(CPACK_PACKAGE_VERSION_PATCH ${thrift_VERSION_PATCH})
+
+### source generator
+set(CPACK_SOURCE_GENERATOR "TGZ")
+set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;tags;cscope.*")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
+
+### zip generator
+set(CPACK_GENERATOR "ZIP")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "thrift")
+
+
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set(CPACK_GENERATOR "NSIS")
+ set(CPACK_NSIS_HELP_LINK "http://thrift.apache.org")
+ set(CPACK_NSIS_MENU_LINKS
+ "http://thrift.apache.org" "Apache Thrift - Web Site"
+ "https://issues.apache.org/jira/browse/THRIFT" "Apache Thrift - Issues")
+ set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
+ set(CPACK_NSIS_MODIFY_PATH "ON")
+ set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
+else()
+ set(CPACK_GENERATOR "DEB" )
+ set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
+endif()
+
+
+include(CPack)
diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake
new file mode 100644
index 000000000..9295d383d
--- /dev/null
+++ b/cmake/ConfigureChecks.cmake
@@ -0,0 +1,75 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+include(CheckSymbolExists)
+include(CheckIncludeFile)
+include(CheckIncludeFiles)
+include(CheckFunctionExists)
+
+# If AI_ADDRCONFIG is not defined we define it as 0
+check_symbol_exists(AI_ADDRCONFIG "sys/types.h;sys/socket.h;netdb.h" HAVE_AI_ADDRCONFIG)
+if(NOT HAVE_AI_ADDRCONFIG)
+set(AI_ADDRCONFIG 1)
+endif(NOT HAVE_AI_ADDRCONFIG)
+
+check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
+check_include_file(fcntl.h HAVE_FCNTL_H)
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+check_include_file(netdb.h HAVE_NETDB_H)
+check_include_file(netinet/in.h HAVE_NETINET_IN_H)
+check_include_file(stdint.h HAVE_STDINT_H)
+check_include_file(unistd.h HAVE_UNISTD_H)
+check_include_file(pthread.h HAVE_PTHREAD_H)
+check_include_file(sys/time.h HAVE_SYS_TIME_H)
+check_include_file(sys/param.h HAVE_SYS_PARAM_H)
+check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
+check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
+check_include_file(sys/stat.h HAVE_SYS_STAT_H)
+check_include_file(sys/un.h HAVE_SYS_UN_H)
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
+check_include_file(sched.h HAVE_SCHED_H)
+check_include_file(strings.h HAVE_STRINGS_H)
+
+check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
+check_function_exists(gethostbyname_r HAVE_GETHOSTBYNAME_R)
+check_function_exists(strerror_r HAVE_STRERROR_R)
+check_function_exists(sched_get_priority_max HAVE_SCHED_GET_PRIORITY_MAX)
+check_function_exists(sched_get_priority_min HAVE_SCHED_GET_PRIORITY_MIN)
+
+include(CheckCSourceCompiles)
+include(CheckCXXSourceCompiles)
+
+check_cxx_source_compiles(
+ "
+ #include <string.h>
+ int main(){char b;char *a = strerror_r(0, &b, 0); return(0);}
+ "
+ STRERROR_R_CHAR_P)
+
+
+set(PACKAGE ${PACKAGE_NAME})
+set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+set(VERSION ${thrift_VERSION})
+
+# generate a config.h file
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/thrift/config.h")
+# HACK: Some files include thrift/config.h and some config.h so we include both. This should be cleaned up.
+include_directories("${CMAKE_CURRENT_BINARY_DIR}/thrift" "${CMAKE_CURRENT_BINARY_DIR}")
diff --git a/cmake/DefineCMakeDefaults.cmake b/cmake/DefineCMakeDefaults.cmake
new file mode 100644
index 000000000..2fe41d37a
--- /dev/null
+++ b/cmake/DefineCMakeDefaults.cmake
@@ -0,0 +1,58 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# Always include srcdir and builddir in include path
+# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
+# about every subdir
+# since cmake 2.4.0
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+# Put the include dirs which are in the source or build tree
+# before all other include dirs, so the headers in the sources
+# are prefered over the already installed ones
+# since cmake 2.4.1
+set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
+
+# Use colored output
+# since cmake 2.4.0
+set(CMAKE_COLOR_MAKEFILE ON)
+
+# Define the generic version of the libraries here
+set(GENERIC_LIB_VERSION "0.1.0")
+set(GENERIC_LIB_SOVERSION "0")
+
+# Set the default build type to release with debug info
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE RelWithDebInfo
+ CACHE STRING
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+ )
+endif (NOT CMAKE_BUILD_TYPE)
+
+# Create the compile command database for clang by default
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
+# Put the libraries and binaries that get built into directories at the
+# top of the build tree rather than in hard-to-find leaf
+# directories. This simplifies manual testing and the use of the build
+# tree rather than installed thrift libraries.
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
diff --git a/cmake/DefineInstallationPaths.cmake b/cmake/DefineInstallationPaths.cmake
new file mode 100644
index 000000000..122f0f6a9
--- /dev/null
+++ b/cmake/DefineInstallationPaths.cmake
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# Define the default install paths
+set(BIN_INSTALL_DIR "bin" CACHE PATH "The binary install dir (default: bin)")
+set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The library install dir (default: lib${LIB_SUFFIX})")
+set(INCLUDE_INSTALL_DIR "include" CACHE PATH "The library install dir (default: include)")
+set(CMAKE_INSTALL_DIR "cmake" CACHE PATH "The subdirectory to install cmake config files (default: cmake)")
+set(DOC_INSTALL_DIR "share/doc" CACHE PATH "The subdirectory to install documentation files (default: share/doc)")
diff --git a/cmake/DefineOptions.cmake b/cmake/DefineOptions.cmake
new file mode 100644
index 000000000..6a3a85dc9
--- /dev/null
+++ b/cmake/DefineOptions.cmake
@@ -0,0 +1,102 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+include(CMakeDependentOption)
+
+# Additional components
+option(BUILD_COMPILER "Build Thrift compiler" ON)
+option(BUILD_TESTING "Build with unit tests" ON)
+option(BUILD_EXAMPLES "Build examples" ON)
+option(BUILD_LIBRARIES "Build Thrfit libraries" ON)
+
+# Libraries to build
+
+# Each language library can be enabled or disabled using the WITH_<LANG> flag.
+# By default CMake checks if the required dependencies for a language are present
+# and enables the library if all are found. This means the default is to build as
+# much as possible but leaving out libraries if their dependencies are not met.
+
+# C++
+find_package(Boost 1.53 QUIET)
+CMAKE_DEPENDENT_OPTION(WITH_CPP "Build C++ library" ON
+ "BUILD_LIBRARIES;Boost_FOUND" OFF)
+# NOTE: Currently the following options are C++ specific,
+# but in future other libraries might reuse them.
+# So they are not dependent on WIHT_CPP but setting them without WITH_CPP currently
+# has no effect.
+find_package(ZLIB QUIET)
+CMAKE_DEPENDENT_OPTION(WITH_ZLIB "Build with ZLIB support" ON
+ "ZLIB_FOUND" OFF)
+find_package(Libevent QUIET)
+CMAKE_DEPENDENT_OPTION(WITH_LIBEVENT "Build with libevent support" ON
+ "Libevent_FOUND" OFF)
+find_package(Qt4 QUIET)
+CMAKE_DEPENDENT_OPTION(WITH_QT4 "Build with Qt4 support" ON
+ "QT4_FOUND" OFF)
+find_package(OpenSSL QUIET)
+CMAKE_DEPENDENT_OPTION(WITH_OPENSSL "Build with OpenSSL support" ON
+ "OpenSSL_FOUND" OFF)
+option(WITH_BOOSTTHREADS "Build with Boost thread support" OFF)
+option(WITH_STDTHREADS "Build with C++ std::thread support" OFF)
+
+# C GLib
+find_package(GLIB QUIET COMPONENTS gobject)
+CMAKE_DEPENDENT_OPTION(WITH_C_GLIB "Build C (GLib) library" ON
+ "BUILD_LIBRARIES;GLIB_FOUND" OFF)
+# Java
+find_package(Java QUIET)
+CMAKE_DEPENDENT_OPTION(WITH_JAVA "Build Java library" ON
+ "BUILD_LIBRARIES;JAVA_FOUND" OFF)
+
+# Common library options
+option(WITH_SHARED_LIB "Build shared libraries" ON)
+option(WITH_STATIC_LIB "Build static libraries" ON)
+
+#NOTE: C++ compiler options are defined in the lib/cpp/CMakeLists.txt
+
+# Visual Studio only options
+if(MSVC)
+option(WITH_MT "Build unsing MT instead of MT (MSVC only)" OFF)
+endif(MSVC)
+
+macro(PRINT_CONFIG_SUMMARY)
+message(STATUS "----------------------------------------------------------")
+message(STATUS "Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
+message(STATUS "Thrift package version: ${PACKAGE_VERSION}")
+message(STATUS "Build configuration Summary")
+message(STATUS " Build Thrift compiler: ${BUILD_COMPILER}")
+message(STATUS " Build with unit tests: ${BUILD_TESTING}")
+message(STATUS " Build examples: ${BUILD_EXAMPLES}")
+message(STATUS " Build Thrfit libraries: ${BUILD_LIBRARIES}")
+message(STATUS " Language libraries:")
+message(STATUS " Build C++ library: ${WITH_CPP}")
+message(STATUS " Build C (GLib) library: ${WITH_C_GLIB}")
+message(STATUS " Build Java library: ${WITH_JAVA}")
+message(STATUS " Library features:")
+message(STATUS " Build shared libraries: ${WITH_SHARED_LIB}")
+message(STATUS " Build static libraries: ${WITH_STATIC_LIB}")
+message(STATUS " Build with ZLIB support: ${WITH_ZLIB}")
+message(STATUS " Build with libevent support: ${WITH_LIBEVENT}")
+message(STATUS " Build with Qt4 support: ${WITH_QT4}")
+message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}")
+message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}")
+message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}")
+message(STATUS "----------------------------------------------------------")
+endmacro(PRINT_CONFIG_SUMMARY)
diff --git a/cmake/DefinePlatformSpecifc.cmake b/cmake/DefinePlatformSpecifc.cmake
new file mode 100644
index 000000000..282cad300
--- /dev/null
+++ b/cmake/DefinePlatformSpecifc.cmake
@@ -0,0 +1,65 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# Visual Studio specific options
+if(MSVC)
+ #For visual studio the library naming is as following:
+ # Dynamic libraries:
+ # - thfirt.dll for release library
+ # - thriftd.dll for debug library
+ #
+ # Static libraries:
+ # - thriftmd.lib for /MD release build
+ # - thriftmt.lib for /MT release build
+ #
+ # - thriftmdd.lib for /MD debug build
+ # - thriftmtd.lib for /MT debug build
+ #
+ # the same holds for other libraries like libthriftz etc.
+
+ # For Debug build types, append a "d" to the library names.
+ set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix" FORCE)
+ set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "Set release library postfix" FORCE)
+
+
+ # Build using /MT option instead of /MD if the WITH_MT options is set
+ if(WITH_MT)
+ set(CompilerFlags
+ CMAKE_CXX_FLAGS
+ CMAKE_CXX_FLAGS_DEBUG
+ CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_C_FLAGS
+ CMAKE_C_FLAGS_DEBUG
+ CMAKE_C_FLAGS_RELEASE
+ )
+ foreach(CompilerFlag ${CompilerFlags})
+ string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
+ endforeach()
+ set(STATIC_POSTFIX "mt" CACHE STRING "Set static library postfix" FORCE)
+ else(WITH_MT)
+ set(STATIC_POSTFIX "md" CACHE STRING "Set static library postfix" FORCE)
+ endif(WITH_MT)
+endif(MSVC)
+
+# GCC Specific
+if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+ # TODO: -pedantic can not be used at the moment because of: https://issues.apache.org/jira/browse/THRIFT-2784
+ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -Wall -Wextra -pedantic")
+endif()
diff --git a/cmake/FindAnt.cmake b/cmake/FindAnt.cmake
new file mode 100644
index 000000000..16b9afda1
--- /dev/null
+++ b/cmake/FindAnt.cmake
@@ -0,0 +1,30 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# Ant_FOUND - system has Ant
+# Ant_EXECUTBALE - the Ant executable
+#
+# It will search the environment variable ANT_HOME if it is set
+
+include(FindPackageHandleStandardArgs)
+
+find_program(Ant_EXECUTABLE NAMES ant PATHS $ENV{ANT_HOME}/bin)
+find_package_handle_standard_args(Ant DEFAULT_MSG Ant_EXECUTABLE)
+mark_as_advanced(Ant_EXECUTABLE)
diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake
new file mode 100644
index 000000000..acbe433e3
--- /dev/null
+++ b/cmake/FindGLIB.cmake
@@ -0,0 +1,122 @@
+# - Try to find Glib and its components (gio, gobject etc)
+# Once done, this will define
+#
+# GLIB_FOUND - system has Glib
+# GLIB_INCLUDE_DIRS - the Glib include directories
+# GLIB_LIBRARIES - link these to use Glib
+#
+# Optionally, the COMPONENTS keyword can be passed to find_package()
+# and Glib components can be looked for. Currently, the following
+# components can be used, and they define the following variables if
+# found:
+#
+# gio: GLIB_GIO_LIBRARIES
+# gobject: GLIB_GOBJECT_LIBRARIES
+# gmodule: GLIB_GMODULE_LIBRARIES
+# gthread: GLIB_GTHREAD_LIBRARIES
+#
+# Note that the respective _INCLUDE_DIR variables are not set, since
+# all headers are in the same directory as GLIB_INCLUDE_DIRS.
+#
+# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
+# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+find_package(PkgConfig)
+pkg_check_modules(PC_GLIB QUIET glib-2.0)
+
+find_library(GLIB_LIBRARIES
+ NAMES glib-2.0
+ HINTS ${PC_GLIB_LIBDIR}
+ ${PC_GLIB_LIBRARY_DIRS}
+)
+
+# Files in glib's main include path may include glibconfig.h, which,
+# for some odd reason, is normally in $LIBDIR/glib-2.0/include.
+get_filename_component(_GLIB_LIBRARY_DIR ${GLIB_LIBRARIES} PATH)
+find_path(GLIBCONFIG_INCLUDE_DIR
+ NAMES glibconfig.h
+ HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${_GLIB_LIBRARY_DIR}
+ ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS}
+ PATH_SUFFIXES glib-2.0/include
+)
+
+find_path(GLIB_INCLUDE_DIR
+ NAMES glib.h
+ HINTS ${PC_GLIB_INCLUDEDIR}
+ ${PC_GLIB_INCLUDE_DIRS}
+ PATH_SUFFIXES glib-2.0
+)
+
+set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIBCONFIG_INCLUDE_DIR})
+
+if(GLIBCONFIG_INCLUDE_DIR)
+ # Version detection
+ file(READ "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h" GLIBCONFIG_H_CONTENTS)
+ string(REGEX MATCH "#define GLIB_MAJOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
+ set(GLIB_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ string(REGEX MATCH "#define GLIB_MINOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
+ set(GLIB_VERSION_MINOR "${CMAKE_MATCH_1}")
+ string(REGEX MATCH "#define GLIB_MICRO_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
+ set(GLIB_VERSION_MICRO "${CMAKE_MATCH_1}")
+ set(GLIB_VERSION "${GLIB_VERSION_MAJOR}.${GLIB_VERSION_MINOR}.${GLIB_VERSION_MICRO}")
+endif()
+
+# Additional Glib components. We only look for libraries, as not all of them
+# have corresponding headers and all headers are installed alongside the main
+# glib ones.
+foreach (_component ${GLIB_FIND_COMPONENTS})
+ if (${_component} STREQUAL "gio")
+ find_library(GLIB_GIO_LIBRARIES NAMES gio-2.0 HINTS ${_GLIB_LIBRARY_DIR})
+ set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GIO_LIBRARIES)
+ elseif (${_component} STREQUAL "gobject")
+ find_library(GLIB_GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${_GLIB_LIBRARY_DIR})
+ set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GOBJECT_LIBRARIES)
+ elseif (${_component} STREQUAL "gmodule")
+ find_library(GLIB_GMODULE_LIBRARIES NAMES gmodule-2.0 HINTS ${_GLIB_LIBRARY_DIR})
+ set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GMODULE_LIBRARIES)
+ elseif (${_component} STREQUAL "gthread")
+ find_library(GLIB_GTHREAD_LIBRARIES NAMES gthread-2.0 HINTS ${_GLIB_LIBRARY_DIR})
+ set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GTHREAD_LIBRARIES)
+ elseif (${_component} STREQUAL "gio-unix")
+ # gio-unix is compiled as part of the gio library, but the include paths
+ # are separate from the shared glib ones. Since this is currently only used
+ # by WebKitGTK+ we don't go to extraordinary measures beyond pkg-config.
+ pkg_check_modules(GIO_UNIX QUIET gio-unix-2.0)
+ endif ()
+endforeach ()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB REQUIRED_VARS GLIB_INCLUDE_DIRS GLIB_LIBRARIES ${ADDITIONAL_REQUIRED_VARS}
+ VERSION_VAR GLIB_VERSION)
+
+mark_as_advanced(
+ GLIBCONFIG_INCLUDE_DIR
+ GLIB_GIO_LIBRARIES
+ GLIB_GIO_UNIX_LIBRARIES
+ GLIB_GMODULE_LIBRARIES
+ GLIB_GOBJECT_LIBRARIES
+ GLIB_GTHREAD_LIBRARIES
+ GLIB_INCLUDE_DIR
+ GLIB_INCLUDE_DIRS
+ GLIB_LIBRARIES
+)
diff --git a/cmake/README.md b/cmake/README.md
new file mode 100644
index 000000000..a5dde191b
--- /dev/null
+++ b/cmake/README.md
@@ -0,0 +1,54 @@
+# Apache Thrift - CMake build
+
+## Goal
+Extend Apache Thrift's *make cross* approach to the build system.
+
+Due to growing the field of operating system support, a proper executable
+and library detection mechanism running on as much platforms as possible
+becomes required. The other aspect to simplify the release process and
+package generation process.
+
+As nice side benefit of CMake is the generation of development environment
+specific soultion files. => No solution files within source tree.
+
+
+## Usage
+just do this:
+
+ mkdir build
+ cmake ${THRIFT_SRC}
+
+if you use a specific toolchain pass it to cmake, the same for options:
+
+ cmake -DCMAKE_TOOLCHAIN_FILE=${THRIFT_SRC}/contrib/mingw32-toolchain.cmake ${THRIFT_SRC}
+ cmake -DTHRIFT_COMPILER_HS=OFF ${THRIFT_SRC}
+ cmake -DWITH_ZLIB=ON ${THRIFT_SRC}
+
+and open the development environment you like with the solution or do this:
+
+ make
+ make check
+ make cross
+ make dist
+
+to generate an installer and distribution package do this:
+
+ cpack
+
+## TODO
+* git hash or tag based versioning depending on source state
+* build tutorial
+* build test
+* with/without language lib/<lang>/
+* enable/disable
+* make check (QUESTION: Is test the default CMake target?)
+* make cross
+* make dist (create an alias to make package_source)
+* make doc
+* cpack (C++ and make dist only ?)
+ * thrift-compiler
+ * libthrift
+ * tutorial
+ * test
+* merge into /README.md
+
diff --git a/cmake/ThriftMacros.cmake b/cmake/ThriftMacros.cmake
new file mode 100644
index 000000000..d35ec1085
--- /dev/null
+++ b/cmake/ThriftMacros.cmake
@@ -0,0 +1,67 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix" FORCE)
+
+
+macro(ADD_LIBRARY_THRIFT name)
+
+if(WITH_SHARED_LIB)
+ add_library(${name} SHARED ${ARGN})
+ #target_link_libraries(${name} ${SYSLIBS})
+ set_target_properties(${name} PROPERTIES
+ OUTPUT_NAME ${name}
+ VERSION ${thrift_VERSION}
+ SOVERSION ${thrift_VERSION} )
+ #set_target_properties(${name} PROPERTIES PUBLIC_HEADER "${thriftcpp_HEADERS}")
+ install(TARGETS ${name}
+ RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
+ PUBLIC_HEADER DESTINATION "${INCLUDE_INSTALL_DIR}")
+endif()
+
+if(WITH_STATIC_LIB)
+ add_library(${name}_static STATIC ${ARGN})
+ #target_link_libraries(${name}_static ${SYSLIBS})
+ set_target_properties(${name}_static PROPERTIES
+ OUTPUT_NAME ${name}${STATIC_POSTFIX}
+ VERSION ${thrift_VERSION}
+ SOVERSION ${thrift_VERSION} )
+ install(TARGETS ${name}_static
+ RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
+ PUBLIC_HEADER DESTINATION "${INCLUDE_INSTALL_DIR}")
+endif()
+
+endmacro()
+
+macro(TARGET_LINK_LIBRARIES_THRIFT name)
+
+if(WITH_SHARED_LIB)
+ target_link_libraries(${name} ${ARGN})
+endif()
+
+if(WITH_STATIC_LIB)
+ target_link_libraries(${name}_static ${ARGN})
+endif()
+
+endmacro() \ No newline at end of file
diff --git a/cmake/config.h.in b/cmake/config.h.in
new file mode 100644
index 000000000..8b75e8c52
--- /dev/null
+++ b/cmake/config.h.in
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* config.h generated by CMake from config.h.in */
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+
+/* Name of package */
+#cmakedefine PACKAGE "${PACKAGE}"
+
+/* Define to the address where bug reports for this package should be sent. */
+#cmakedefine PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}"
+
+/* Define to the full name of this package. */
+#cmakedefine PACKAGE_NAME "${PACKAGE_NAME}"
+
+/* Define to the one symbol short name of this package. */
+#cmakedefine PACKAGE_TARNAME "${PACKAGE_TARNAME}"
+
+/* Define to the home page for this package. */
+#cmakedefine PACKAGE_URL "${PACKAGE_URL}"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "${PACKAGE_VERSION}"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "${PACKAGE_STRING}"
+
+/* Version number of package */
+#define VERSION "${VERSION}"
+
+/************************** DEFINES *************************/
+
+/* Define if the AI_ADDRCONFIG symbol is unavailable */
+#cmakedefine AI_ADDRCONFIG 0
+
+/* Possible value for SIGNED_RIGHT_SHIFT_IS */
+/* TODO: This is just set to 1 for the moment
+ port the macro aclocal/ax_signed_right_shift.m4 to CMake to make this work */
+#define ARITHMETIC_RIGHT_SHIFT 1
+
+/* Indicates the effect of the right shift operator on negative signed
+ integers */
+/* TODO: This is just set to 1 for the moment */
+#define SIGNED_RIGHT_SHIFT_IS 1
+
+/* Use *.h extension for parser header file */
+/* TODO: This might now be necessary anymore as it is set onyl for automake < 1.11
+ see: aclocal/ac_prog_bison.m4 */
+#cmakedefine BISON_USE_PARSER_H_EXTENSION 1
+
+/* replaces POSIX pthread by boost::thread */
+#cmakedefine USE_BOOST_THREAD 1
+
+/* replaces POSIX pthread by std::thread */
+#cmakedefine USE_STD_THREAD 1
+
+/* Define to 1 if strerror_r returns char *. */
+#cmakedefine STRERROR_R_CHAR_P 1
+
+
+/************************** HEADER FILES *************************/
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#cmakedefine HAVE_ARPA_INET_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#cmakedefine HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#cmakedefine HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#cmakedefine HAVE_NETDB_H 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#cmakedefine HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#cmakedefine HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the <pthread.h> header file. */
+#cmakedefine HAVE_PTHREAD_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#cmakedefine HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#cmakedefine HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#cmakedefine HAVE_SYS_RESOURCE_H 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#cmakedefine HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#cmakedefine HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/un.h> header file. */
+#cmakedefine HAVE_SYS_UN_H 1
+
+/* Define to 1 if you have the <sys/poll.h> header file. */
+#cmakedefine HAVE_SYS_POLL_H 1
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#cmakedefine HAVE_SYS_SELECT_H 1
+
+/* Define to 1 if you have the <sched.h> header file. */
+#cmakedefine HAVE_SCHED_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/*************************** FUNCTIONS ***************************/
+
+/* Define to 1 if you have the `gethostbyname' function. */
+#cmakedefine HAVE_GETHOSTBYNAME 1
+
+/* Define to 1 if you have the `gethostbyname_r' function. */
+#cmakedefine HAVE_GETHOSTBYNAME_R 1
+
+/* Define to 1 if you have the `strerror_r' function. */
+#cmakedefine HAVE_STRERROR_R 1
+
+/* Define to 1 if you have the `sched_get_priority_max' function. */
+#cmakedefine HAVE_SCHED_GET_PRIORITY_MAX 1
+
+/* Define to 1 if you have the `sched_get_priority_min' function. */
+#cmakedefine HAVE_SCHED_GET_PRIORITY_MIN 1
+
+
+/* Define to 1 if strerror_r returns char *. */
+#cmakedefine STRERROR_R_CHAR_P 1
+
+#endif \ No newline at end of file
diff --git a/compiler/cpp/CMakeLists.txt b/compiler/cpp/CMakeLists.txt
index 4ed8b2bae..ddbe9ea49 100644
--- a/compiler/cpp/CMakeLists.txt
+++ b/compiler/cpp/CMakeLists.txt
@@ -20,22 +20,6 @@
cmake_minimum_required(VERSION 2.8)
-project(thrift-compiler)
-
-# Read the version information from the Autoconf file
-file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/../../configure.ac" CONFIGURE_AC REGEX "AC_INIT\\(.*\\)" )
-
-# The following variable is used in the version.h.in file
-string(REGEX REPLACE "AC_INIT\\(\\[.*\\], \\[([0-9]+\\.[0-9]+\\.[0-9]+(-dev)?)\\]\\)" "\\1" PACKAGE_VERSION ${CONFIGURE_AC})
-message(STATUS "Thrift package version: ${PACKAGE_VERSION}")
-
-# These are internal to CMake
-string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+)(-dev)?" "\\1" thrift_VERSION ${PACKAGE_VERSION})
-string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" thrift_VERSION_MAJOR ${thrift_VERSION})
-string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" thrift_VERSION_MINOR ${thrift_VERSION})
-string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" thrift_VERSION_PATCH ${thrift_VERSION})
-message(STATUS "Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
-
# Windows has a different header
if(MSVC)
set(FLEX_FLAGS "--wincompat") # Don't use unistd.h on windows
@@ -145,44 +129,9 @@ THRIFT_ADD_COMPILER(lua "Enable compiler for Lua" ON)
# we also add the current binary directory for generated files
include_directories(${CMAKE_CURRENT_BINARY_DIR} src)
-add_executable(thrift ${thrift_SOURCES})
+add_executable(thrift-compiler ${thrift_SOURCES})
+set_target_properties(thrift-compiler PROPERTIES OUTPUT_NAME thrift)
-target_link_libraries(thrift libparse)
-
-install(TARGETS thrift DESTINATION bin)
-
-# mingw32 does not support c++0x features
-if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-endif()
+target_link_libraries(thrift-compiler libparse)
-if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
-endif()
-
-
-# create a Distribution Package for the Apache Thrift Compiler
-set(CPACK_PACKAGE_NAME "Apache Thrift")
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Apache Thrift Compiler")
-set(CPACK_PACKAGE_VENDOR "Apache Software Foundation" )
-set(CPACK_PACKAGE_CONTACT "dev@thrift.apache.org")
-set(CPACK_PACKAGE_VERSION ${thrift_VERSION})
-set(CPACK_PACKAGE_VERSION_MAJOR ${thrift_VERSION_MAJOR} )
-set(CPACK_PACKAGE_VERSION_MINOR ${thrift_VERSION_MINOR} )
-set(CPACK_PACKAGE_VERSION_PATCH ${thrift_VERSION_PATCH} )
-set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../../LICENSE")
-
-if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
- set(CPACK_GENERATOR "NSIS")
- set(CPACK_NSIS_HELP_LINK "http://thrift.apache.org")
- set(CPACK_NSIS_MENU_LINKS
- "http://thrift.apache.org" "Apache Thrift - Web Site"
- "https://issues.apache.org/jira/browse/THRIFT" "Apache Thrift - Issues")
- set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
- set(CPACK_NSIS_MODIFY_PATH "ON")
- set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
-else()
- set(CPACK_GENERATOR "DEB" )
- set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
-endif()
-include(CPack)
+install(TARGETS thrift-compiler DESTINATION "${BIN_INSTALL_DIR}")
diff --git a/lib/c_glib/CMakeLists.txt b/lib/c_glib/CMakeLists.txt
new file mode 100644
index 000000000..b5cb696ef
--- /dev/null
+++ b/lib/c_glib/CMakeLists.txt
@@ -0,0 +1,69 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+cmake_minimum_required(VERSION 2.8)
+
+# Find required packages
+find_package(GLIB REQUIRED COMPONENTS gobject)
+include_directories(${GLIB_INCLUDE_DIRS})
+
+include_directories(src)
+
+# SYSLIBS contains libraries that need to be linked to all lib targets
+set(SYSLIBS ${GLIB_LIBRARIES} ${GLIB_GOBJECT_LIBRARIES})
+
+# Create the thrift C glib library
+set(thrift_c_glib_SOURCES
+ src/thrift/c_glib/thrift.c
+ src/thrift/c_glib/thrift_struct.c
+ src/thrift/c_glib/thrift_application_exception.c
+ src/thrift/c_glib/processor/thrift_processor.c
+ src/thrift/c_glib/processor/thrift_dispatch_processor.c
+ src/thrift/c_glib/protocol/thrift_protocol.c
+ src/thrift/c_glib/protocol/thrift_protocol_factory.c
+ src/thrift/c_glib/protocol/thrift_binary_protocol.c
+ src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c
+ src/thrift/c_glib/transport/thrift_transport.c
+ src/thrift/c_glib/transport/thrift_transport_factory.c
+ src/thrift/c_glib/transport/thrift_buffered_transport_factory.c
+ src/thrift/c_glib/transport/thrift_framed_transport_factory.c
+ src/thrift/c_glib/transport/thrift_socket.c
+ src/thrift/c_glib/transport/thrift_server_transport.c
+ src/thrift/c_glib/transport/thrift_server_socket.c
+ src/thrift/c_glib/transport/thrift_buffered_transport.c
+ src/thrift/c_glib/transport/thrift_framed_transport.c
+ src/thrift/c_glib/transport/thrift_memory_buffer.c
+ src/thrift/c_glib/server/thrift_server.c
+ src/thrift/c_glib/server/thrift_simple_server.c
+)
+
+# Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT
+include(ThriftMacros)
+
+ADD_LIBRARY_THRIFT(thrift_c_glib ${thrift_c_glib_SOURCES})
+TARGET_LINK_LIBRARIES_THRIFT(thrift_c_glib ${SYSLIBS})
+
+# Install the headers
+install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
+ FILES_MATCHING PATTERN "*.h")
+
+if(BUILD_TESTING)
+ add_subdirectory(test)
+endif()
diff --git a/lib/c_glib/test/CMakeLists.txt b/lib/c_glib/test/CMakeLists.txt
new file mode 100644
index 000000000..affa45581
--- /dev/null
+++ b/lib/c_glib/test/CMakeLists.txt
@@ -0,0 +1,168 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+#Make sure gen-cpp and gen-c_glib files can be included
+include_directories("${CMAKE_CURRENT_BINARY_DIR}")
+
+set(TEST_PREFIX "c_glib")
+
+# Create the thrift C++ test library
+set(testgenc_SOURCES
+ gen-c_glib/t_test_debug_proto_test_types.c
+ gen-c_glib/t_test_empty_service.c
+ gen-c_glib/t_test_inherited.c
+ gen-c_glib/t_test_optional_required_test_types.c
+ gen-c_glib/t_test_reverse_order_service.c
+ gen-c_glib/t_test_second_service.c
+ gen-c_glib/t_test_service_for_exception_with_a_map.c
+ gen-c_glib/t_test_srv.c
+ gen-c_glib/t_test_thrift_test.c
+ gen-c_glib/t_test_thrift_test_types.c
+ gen-c_glib/t_test_debug_proto_test_types.h
+ gen-c_glib/t_test_empty_service.h
+ gen-c_glib/t_test_inherited.h
+ gen-c_glib/t_test_optional_required_test_types.h
+ gen-c_glib/t_test_reverse_order_service.h
+ gen-c_glib/t_test_second_service.h
+ gen-c_glib/t_test_service_for_exception_with_a_map.h
+ gen-c_glib/t_test_srv.h
+ gen-c_glib/t_test_thrift_test.h
+ gen-c_glib/t_test_thrift_test_types.h
+)
+
+add_library(testgenc STATIC ${testgenc_SOURCES})
+target_link_libraries(testgenc thrift_c_glib)
+
+
+add_executable(testapplicationexception testapplicationexception.c)
+target_link_libraries(testapplicationexception thrift_c_glib)
+add_test(NAME testapplicationexception COMMAND testapplicationexception)
+
+add_executable(testtransportsocket testtransportsocket.c)
+target_link_libraries(testtransportsocket thrift_c_glib)
+add_test(NAME testtransportsocket COMMAND testtransportsocket)
+
+add_executable(testbinaryprotocol testbinaryprotocol.c)
+target_link_libraries(testbinaryprotocol thrift_c_glib)
+add_test(NAME testbinaryprotocol COMMAND testbinaryprotocol)
+
+add_executable(testbufferedtransport testbufferedtransport.c)
+target_link_libraries(testbufferedtransport thrift_c_glib)
+add_test(NAME testbufferedtransport COMMAND testbufferedtransport)
+
+add_executable(testframedtransport testframedtransport.c)
+target_link_libraries(testframedtransport thrift_c_glib)
+add_test(NAME testframedtransport COMMAND testframedtransport)
+
+add_executable(testmemorybuffer testmemorybuffer.c)
+target_link_libraries(testmemorybuffer thrift_c_glib)
+add_test(NAME testmemorybuffer COMMAND testmemorybuffer)
+
+add_executable(testsimpleserver testsimpleserver.c)
+target_link_libraries(testsimpleserver thrift_c_glib)
+add_test(NAME testsimpleserver COMMAND testsimpleserver)
+
+add_executable(testdebugproto testdebugproto.c)
+target_link_libraries(testdebugproto testgenc)
+add_test(NAME testdebugproto COMMAND testdebugproto)
+
+add_executable(testoptionalrequired testoptionalrequired.c)
+target_link_libraries(testoptionalrequired testgenc)
+add_test(NAME testoptionalrequired COMMAND testoptionalrequired)
+
+add_executable(testthrifttest testthrifttest.c)
+target_link_libraries(testthrifttest testgenc)
+add_test(NAME testthrifttest COMMAND testthrifttest)
+
+
+if(WITH_CPP)
+
+ include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src")
+
+ # Create the thrift C++ test library
+ set(testgenc_cpp_SOURCES
+ gen-cpp/ThriftTest.cpp
+ gen-cpp/ThriftTest_constants.cpp
+ gen-cpp/ThriftTest_types.cpp
+ gen-cpp/ThriftTest.h
+ gen-cpp/ThriftTest_constants.h
+ gen-cpp/ThriftTest_types.h
+ )
+
+ add_library(testgenc_cpp STATIC ${testgenc_cpp_SOURCES})
+ target_link_libraries(testgenc_cpp thrift)
+
+ #HACK: testthrifttestclient.cpp includes ThriftTest.h without gen-*/ prefixes
+ # so we include it here
+ include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp" "${CMAKE_CURRENT_BINARY_DIR}/gen-c_glib")
+
+ add_executable(testthrifttestclient testthrifttestclient.cpp)
+ target_link_libraries(testthrifttestclient testgenc testgenc_cpp)
+ add_test(NAME testthrifttestclient COMMAND testthrifttestclient)
+
+endif(WITH_CPP)
+
+#
+# Common thrift code generation rules
+#
+
+add_custom_command(OUTPUT
+ gen-c_glib/t_test_debug_proto_test_types.c
+ gen-c_glib/t_test_debug_proto_test_types.h
+ gen-c_glib/t_test_empty_service.c
+ gen-c_glib/t_test_empty_service.h
+ gen-c_glib/t_test_inherited.c
+ gen-c_glib/t_test_inherited.h
+ gen-c_glib/t_test_reverse_order_service.c
+ gen-c_glib/t_test_reverse_order_service.h
+ gen-c_glib/t_test_service_for_exception_with_a_map.c
+ gen-c_glib/t_test_service_for_exception_with_a_map.h
+ gen-c_glib/t_test_srv.c
+ gen-c_glib/t_test_srv.h
+ COMMAND thrift-compiler --gen c_glib ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift
+)
+
+add_custom_command(OUTPUT
+ gen-c_glib/t_test_optional_required_test_types.c
+ gen-c_glib/t_test_optional_required_test_types.h
+ COMMAND thrift-compiler --gen c_glib ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift
+)
+
+add_custom_command(OUTPUT
+ gen-c_glib/t_test_second_service.c
+ gen-c_glib/t_test_thrift_test.c
+ gen-c_glib/t_test_thrift_test_types.c
+ gen-c_glib/t_test_second_service.h
+ gen-c_glib/t_test_thrift_test.h
+ gen-c_glib/t_test_thrift_test_types.h
+ COMMAND thrift-compiler --gen c_glib ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
+)
+
+add_custom_command(OUTPUT
+ gen-cpp/ThriftTest.cpp
+ gen-cpp/ThriftTest_constants.cpp
+ gen-cpp/ThriftTest_types.cpp
+ gen-cpp/ThriftTest.h
+ gen-cpp/ThriftTest_constants.h
+ gen-cpp/ThriftTest_types.h
+ COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
+)
+
+# TODO: Add memory checks using ctest_memcheck or similar
diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt
new file mode 100755
index 000000000..cc73f994d
--- /dev/null
+++ b/lib/cpp/CMakeLists.txt
@@ -0,0 +1,189 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+cmake_minimum_required(VERSION 2.8)
+
+# Find required packages
+find_package(Boost 1.53.0 REQUIRED)
+include_directories("${Boost_INCLUDE_DIR}")
+
+include_directories(src)
+
+# SYSLIBS contains libraries that need to be linked to all lib targets
+set(SYSLIBS "")
+
+# Create the thrift C++ library
+set( thriftcpp_SOURCES
+ src/thrift/Thrift.cpp
+ src/thrift/TApplicationException.cpp
+ src/thrift/VirtualProfiling.cpp
+ src/thrift/concurrency/ThreadManager.cpp
+ src/thrift/concurrency/TimerManager.cpp
+ src/thrift/concurrency/Util.cpp
+ src/thrift/protocol/TDebugProtocol.cpp
+ src/thrift/protocol/TDenseProtocol.cpp
+ src/thrift/protocol/TJSONProtocol.cpp
+ src/thrift/protocol/TBase64Utils.cpp
+ src/thrift/protocol/TMultiplexedProtocol.cpp
+ src/thrift/transport/TTransportException.cpp
+ src/thrift/transport/TFDTransport.cpp
+ src/thrift/transport/TSimpleFileTransport.cpp
+ src/thrift/transport/THttpTransport.cpp
+ src/thrift/transport/THttpClient.cpp
+ src/thrift/transport/THttpServer.cpp
+ src/thrift/transport/TSocket.cpp
+ src/thrift/transport/TSocketPool.cpp
+ src/thrift/transport/TServerSocket.cpp
+ src/thrift/transport/TTransportUtils.cpp
+ src/thrift/transport/TBufferTransports.cpp
+ src/thrift/server/TServer.cpp
+ src/thrift/server/TSimpleServer.cpp
+ src/thrift/server/TThreadPoolServer.cpp
+ src/thrift/server/TThreadedServer.cpp
+ src/thrift/async/TAsyncChannel.cpp
+ src/thrift/processor/PeekProcessor.cpp
+)
+
+# This files don't work on Windows CE as there is no pipe support
+# TODO: This files won't work with UNICODE support on windows. If fixed this can be re-added.
+if (NOT WINCE)
+ list(APPEND thriftcpp_SOURCES
+ src/thrift/transport/TPipe.cpp
+ src/thrift/transport/TPipeServer.cpp
+ src/thrift/transport/TFileTransport.cpp
+ )
+endif()
+
+
+if (WIN32)
+ list(APPEND thriftcpp_SOURCES
+ src/thrift/windows/TWinsockSingleton.cpp
+ src/thrift/windows/SocketPair.cpp
+ src/thrift/windows/GetTimeOfDay.cpp
+ src/thrift/windows/WinFcntl.cpp
+ )
+ if(NOT WINCE)
+ # This file uses pipes so it currently won't work on Windows CE
+ list(APPEND thriftcpp_SOURCES
+ src/thrift/windows/OverlappedSubmissionThread.cpp
+ )
+ endif()
+endif()
+
+# If OpenSSL is not found just ignore the OpenSSL stuff
+find_package(OpenSSL)
+if(OPENSSL_FOUND AND WITH_OPENSSL)
+ list( APPEND thriftcpp_SOURCES
+ src/thrift/transport/TSSLSocket.cpp
+ src/thrift/transport/TSSLServerSocket.cpp
+ )
+ include_directories("${OPENSSL_INCLUDE_DIR}")
+ list(APPEND SYSLIBS "${OPENSSL_LIBRARIES}")
+endif()
+
+# WITH_*THREADS selects whicht threading library to use
+if(WITH_BOOSTTHREADS)
+ set( USE_BOOST_THREAD 1)
+ set( thriftcpp_threads_SOURCES
+ src/thrift/concurrency/BoostThreadFactory.cpp
+ src/thrift/concurrency/BoostMonitor.cpp
+ src/thrift/concurrency/BoostMutex.cpp
+ )
+ list(APPEND SYSLIBS "${Boost_LIBRARIES}")
+elseif(UNIX AND NOT WITH_STDTHREADS)
+ list(APPEND SYSLIBS pthread)
+ set( thriftcpp_threads_SOURCES
+ src/thrift/concurrency/PosixThreadFactory.cpp
+ src/thrift/concurrency/Mutex.cpp
+ src/thrift/concurrency/Monitor.cpp
+ )
+else()
+ set( USE_STD_THREAD 1)
+ set( thriftcpp_threads_SOURCES
+ src/thrift/concurrency/StdThreadFactory.cpp
+ src/thrift/concurrency/StdMutex.cpp
+ src/thrift/concurrency/StdMonitor.cpp
+ )
+endif()
+
+# Thrift non blocking server
+set( thriftcppnb_SOURCES
+ src/thrift/server/TNonblockingServer.cpp
+ src/thrift/async/TAsyncProtocolProcessor.cpp
+ src/thrift/async/TEvhttpServer.cpp
+ src/thrift/async/TEvhttpClientChannel.cpp
+)
+
+# Thrift zlib server
+set( thriftcppz_SOURCES
+ src/thrift/transport/TZlibTransport.cpp
+)
+
+# Thrift Qt4 server
+set( thriftcppqt_SOURCES
+ src/thrift/qt/TQIODeviceTransport.cpp
+ src/thrift/qt/TQTcpServer.cpp
+)
+
+# Contains the thrift specific ADD_LIBRARY_THRIFT and TARGET_LINK_LIBRARIES_THRIFT
+include(ThriftMacros)
+
+ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES})
+TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS})
+
+if(WITH_LIBEVENT)
+ find_package(Libevent REQUIRED) # Libevent comes with CMake support form upstream
+ include_directories(${Libevent_INCLUDE_DIR})
+
+ ADD_LIBRARY_THRIFT(thriftnb ${thriftcppnb_SOURCES})
+ TARGET_LINK_LIBRARIES_THRIFT(thriftnb ${SYSLIBS} ${Libevent_LIBRARIES})
+endif()
+
+if(WITH_ZLIB)
+ find_package(ZLIB REQUIRED)
+ include_directories(${ZLIB_INCLUDE_DIR})
+
+ ADD_LIBRARY_THRIFT(thriftz ${thriftcppz_SOURCES})
+ TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${ZLIB_LIBRARIES})
+endif()
+
+
+if(WITH_QT4)
+ find_package(Qt4 REQUIRED)
+ include_directories(${QT_INCLUDES})
+
+ ADD_LIBRARY_THRIFT(thriftqt ${thriftcppqt_SOURCES})
+ TARGET_LINK_LIBRARIES_THRIFT(thriftz ${SYSLIBS} ${QT_LIBRARIES})
+endif()
+
+if(MSVC)
+ add_definitions("-DUNICODE -D_UNICODE")
+endif()
+
+# Install the headers
+install(DIRECTORY "src/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
+ FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc")
+# Copy config.h file
+install(DIRECTORY "${CMAKE_BINARY_DIR}/thrift" DESTINATION "${INCLUDE_INSTALL_DIR}"
+ FILES_MATCHING PATTERN "*.h")
+
+if(BUILD_TESTING)
+ add_subdirectory(test)
+endif()
diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt
new file mode 100644
index 000000000..cb685059f
--- /dev/null
+++ b/lib/cpp/test/CMakeLists.txt
@@ -0,0 +1,255 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+# Find required packages
+set(Boost_USE_STATIC_LIBS ON) # Force the use of static boost test framework
+find_package(Boost 1.53.0 REQUIRED COMPONENTS unit_test_framework)
+include_directories("${Boost_INCLUDE_DIR}")
+
+#Make sure gen-cpp files can be included
+include_directories("${CMAKE_CURRENT_BINARY_DIR}")
+
+# Create the thrift C++ test library
+set(testgencpp_SOURCES
+ gen-cpp/DebugProtoTest_types.cpp
+ gen-cpp/DebugProtoTest_types.h
+ gen-cpp/EnumTest_types.cpp
+ gen-cpp/EnumTest_types.h
+ gen-cpp/OptionalRequiredTest_types.cpp
+ gen-cpp/OptionalRequiredTest_types.h
+ gen-cpp/Recursive_types.cpp
+ gen-cpp/Recursive_types.h
+ gen-cpp/ThriftTest_types.cpp
+ gen-cpp/ThriftTest_types.h
+ gen-cpp/TypedefTest_types.cpp
+ gen-cpp/TypedefTest_types.h
+ ThriftTest_extras.cpp
+ DebugProtoTest_extras.cpp
+)
+
+add_library(testgencpp STATIC ${testgencpp_SOURCES})
+target_link_libraries(testgencpp thrift)
+
+set(processortest_SOURCES
+ gen-cpp/ChildService.cpp
+ gen-cpp/ChildService.h
+ gen-cpp/ParentService.cpp
+ gen-cpp/ParentService.h
+ gen-cpp/proc_types.cpp
+ gen-cpp/proc_types.h
+)
+
+
+add_executable(Benchmark Benchmark.cpp)
+target_link_libraries(Benchmark testgencpp)
+add_test(NAME Benchmark COMMAND Benchmark)
+
+set(UnitTest_SOURCES
+ UnitTestMain.cpp
+ TMemoryBufferTest.cpp
+ TBufferBaseTest.cpp
+ Base64Test.cpp
+ ToStringTest.cpp
+ TypedefTest.cpp
+)
+
+if(NOT WITH_BOOSTTHREADS AND NOT WITH_STDTHREADS)
+ list(APPEND UnitTest_SOURCES RWMutexStarveTest.cpp)
+endif()
+
+add_executable(UnitTests ${UnitTest_SOURCES})
+target_link_libraries(UnitTests testgencpp thrift ${Boost_LIBRARIES})
+add_test(NAME UnitTests COMMAND UnitTests)
+
+
+if(WITH_ZLIB)
+add_executable(TransportTest TransportTest.cpp)
+target_link_libraries(TransportTest
+ testgencpp
+ thriftz
+ ${Boost_LIBRARIES}
+ ${ZLIB_LIBRARIES}
+)
+add_test(NAME TransportTest COMMAND TransportTest)
+
+add_executable(ZlibTest ZlibTest.cpp)
+target_link_libraries(ZlibTest
+ testgencpp
+ thriftz
+ ${Boost_LIBRARIES}
+ ${ZLIB_LIBRARIES}
+)
+add_test(NAME ZlibTest COMMAND ZlibTest)
+endif(WITH_ZLIB)
+
+
+add_executable(EnumTest EnumTest.cpp)
+target_link_libraries(EnumTest
+ testgencpp
+ ${Boost_LIBRARIES}
+)
+add_test(NAME EnumTest COMMAND EnumTest)
+
+add_executable(TFileTransportTest TFileTransportTest.cpp)
+target_link_libraries(TFileTransportTest
+ testgencpp
+ ${Boost_LIBRARIES}
+)
+add_test(NAME TFileTransportTest COMMAND TFileTransportTest)
+
+add_executable(TFDTransportTest TFDTransportTest.cpp)
+target_link_libraries(TFDTransportTest
+ thrift
+)
+add_test(NAME TFDTransportTest COMMAND TFDTransportTest)
+
+add_executable(TPipedTransportTest TPipedTransportTest.cpp)
+target_link_libraries(TPipedTransportTest
+ thrift
+)
+add_test(NAME TPipedTransportTest COMMAND TPipedTransportTest)
+
+set(AllProtocolsTest_SOURCES
+ AllProtocolTests.cpp
+ AllProtocolTests.tcc
+ GenericHelpers
+ )
+
+add_executable(AllProtocolsTest ${AllProtocolsTest_SOURCES})
+target_link_libraries(AllProtocolsTest
+ testgencpp
+)
+add_test(NAME AllProtocolsTest COMMAND AllProtocolsTest)
+
+add_executable(DebugProtoTest DebugProtoTest.cpp)
+target_link_libraries(DebugProtoTest
+ testgencpp
+)
+add_test(NAME DebugProtoTest COMMAND DebugProtoTest)
+
+add_executable(JSONProtoTest JSONProtoTest.cpp)
+target_link_libraries(JSONProtoTest
+ testgencpp
+)
+add_test(NAME JSONProtoTest COMMAND JSONProtoTest)
+
+add_executable(OptionalRequiredTest OptionalRequiredTest.cpp)
+target_link_libraries(OptionalRequiredTest
+ testgencpp
+)
+add_test(NAME OptionalRequiredTest COMMAND OptionalRequiredTest)
+
+add_executable(RecursiveTest RecursiveTest.cpp)
+target_link_libraries(RecursiveTest
+ testgencpp
+)
+add_test(NAME RecursiveTest COMMAND RecursiveTest)
+
+add_executable(SpecializationTest SpecializationTest.cpp)
+target_link_libraries(SpecializationTest
+ testgencpp
+)
+add_test(NAME SpecializationTest COMMAND SpecializationTest)
+
+set(concurrency_test_SOURCES
+ concurrency/Tests.cpp
+ concurrency/ThreadFactoryTests.h
+ concurrency/ThreadManagerTests.h
+ concurrency/TimerManagerTests.h
+)
+add_executable(concurrency_test ${concurrency_test_SOURCES})
+target_link_libraries(concurrency_test
+ thrift
+)
+add_test(NAME concurrency_test COMMAND concurrency_test)
+
+set(link_test_SOURCES
+ link/LinkTest.cpp
+ link/TemplatedService1.cpp
+ link/TemplatedService2.cpp
+ gen-cpp/ParentService.h
+)
+add_executable(link_test ${link_test_SOURCES})
+add_test(NAME link_test COMMAND link_test)
+
+if(WITH_LIBEVENT)
+set(processor_test_SOURCES
+ processor/ProcessorTest.cpp
+ processor/EventLog.cpp
+ processor/ServerThread.cpp
+ processor/EventLog.h
+ processor/Handlers.h
+ processor/ServerThread.h
+)
+add_executable(processor_test ${processor_test_SOURCES})
+target_link_libraries(processor_test
+ thrift
+ thriftnb
+ ${Boost_LIBRARIES}
+)
+add_test(NAME processor_test COMMAND processor_test)
+endif()
+
+if(OPENSSL_FOUND AND WITH_OPENSSL)
+add_executable(OpenSSLManualInitTest OpenSSLManualInitTest.cpp)
+target_link_libraries(OpenSSLManualInitTest
+ thrift
+ ${OPENSSL_LIBRARIES}
+ ${Boost_LIBRARIES}
+)
+add_test(NAME OpenSSLManualInitTest COMMAND OpenSSLManualInitTest)
+endif()
+
+#
+# Common thrift code generation rules
+#
+
+
+add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h
+ COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift
+)
+
+add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h
+ COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift
+)
+
+add_custom_command(OUTPUT gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h
+ COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift
+)
+
+add_custom_command(OUTPUT gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h
+ COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift
+)
+
+add_custom_command(OUTPUT gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h
+ COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift
+)
+
+add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp
+ COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
+)
+
+add_custom_command(OUTPUT gen-cpp/SecondService.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_types.h
+ COMMAND thrift-compiler --gen cpp:dense ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
+)
+
+add_custom_command(OUTPUT gen-cpp/ChildService.cpp gen-cpp/ChildService.h gen-cpp/ParentService.cpp gen-cpp/ParentService.h gen-cpp/proc_types.cpp gen-cpp/proc_types.h
+ COMMAND thrift-compiler --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift
+)
diff --git a/lib/java/CMakeLists.txt b/lib/java/CMakeLists.txt
new file mode 100644
index 000000000..83063188a
--- /dev/null
+++ b/lib/java/CMakeLists.txt
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+cmake_minimum_required(VERSION 2.8)
+
+# Find required packages
+find_package(Ant REQUIRED)
+
+if(IS_ABSOLUTE "${LIB_INSTALL_DIR}")
+ set(JAVA_INSTALL_DIR "${LIB_INSTALL_DIR}/java")
+else()
+ set(JAVA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/java")
+endif()
+
+if(IS_ABSOLUTE "${DOC_INSTALL_DIR}")
+ set(JAVA_DOC_INSTALL_DIR "${DOC_INSTALL_DIR}/java")
+else()
+ set(JAVA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_DIR}/java")
+endif()
+
+add_custom_target(ant_build ALL
+ COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir} -f build.xml
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMENT "Building Java library using Ant"
+)
+
+# Hook the ant install task into CMake install
+install(CODE "execute_process(
+ COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} install
+ -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir}
+ -Dinstall.path=${JAVA_INSTALL_DIR} -Dinstall.javadoc.path=${JAVA_DOC_INSTALL_DIR} -f build.xml
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)")
+
+if(BUILD_TESTING)
+ #add_subdirectory(test)
+endif()