THRIFT-4811: Add CMake config file and targets. (see #4752) (#1748)

* Add CMake config file and targets. (see #4752)
* Exclude cygwin

Co-Authored-By: soroshsabz <soorosh_abi@hotmail.com>
diff --git a/build/cmake/ThriftMacros.cmake b/build/cmake/ThriftMacros.cmake
index 8f370df..d068b2a 100644
--- a/build/cmake/ThriftMacros.cmake
+++ b/build/cmake/ThriftMacros.cmake
@@ -23,18 +23,26 @@
         DESTINATION "${PKGCONFIG_INSTALL_DIR}")
 endmacro(ADD_PKGCONFIG_THRIFT)
 
-
 macro(ADD_LIBRARY_THRIFT name)
     add_library(${name} ${ARGN})
     set_target_properties(${name} PROPERTIES
         OUTPUT_NAME ${name}${THRIFT_RUNTIME_POSTFIX}   # windows link variants (/MT, /MD, /MTd, /MDd) get different names
         VERSION ${thrift_VERSION} )
     # set_target_properties(${name} PROPERTIES PUBLIC_HEADER "${thriftcpp_HEADERS}")
-    install(TARGETS ${name}
+    install(TARGETS ${name} EXPORT "${name}Targets"
         RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
         LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
         ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
         PUBLIC_HEADER DESTINATION "${INCLUDE_INSTALL_DIR}")
+
+	export(EXPORT "${name}Targets"
+		FILE "${CMAKE_CURRENT_BINARY_DIR}/${name}/${name}Targets.cmake"
+		NAMESPACE "${name}::")
+
+	install(EXPORT "${name}Targets"
+		FILE "${name}Targets.cmake"
+		NAMESPACE "${name}::"
+		DESTINATION "${CMAKE_INSTALL_DIR}/thrift")
 endmacro()
 
 macro(TARGET_INCLUDE_DIRECTORIES_THRIFT name)