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>
diff --git a/compiler/cpp/CMakeLists.txt b/compiler/cpp/CMakeLists.txt
index 4ed8b2b..ddbe9ea 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 @@
 # 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)
+target_link_libraries(thrift-compiler 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()
-
-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}")