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/cmake/ThriftMacros.cmake b/cmake/ThriftMacros.cmake
new file mode 100644
index 0000000..d35ec10
--- /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