THRIFT-2835 Add possibility to distribute generators separately from thrift core, and load them dynamically
Client: Compiler
Patch: Nobuaki Sukegawa, rebased by dtmuller

Also fixed by dtmuller:
* Add plugin namespace for erlang language binding
* Fix unit test test_const_value
* Don't clear type cache with every t_program conversion
* Type "wb" may not be supported by popen on non-Windows platforms
* Fix constness of AST type signatures
diff --git a/build/cmake/ThriftMacros.cmake b/build/cmake/ThriftMacros.cmake
index 2656598..f837f94 100644
--- a/build/cmake/ThriftMacros.cmake
+++ b/build/cmake/ThriftMacros.cmake
@@ -25,7 +25,6 @@
 
 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}
@@ -40,7 +39,6 @@
 
 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}
@@ -55,6 +53,19 @@
 endmacro(ADD_LIBRARY_THRIFT)
 
 
+macro(TARGET_INCLUDE_DIRECTORIES_THRIFT name)
+
+if(WITH_SHARED_LIB)
+    target_include_directories(${name} ${ARGN})
+endif()
+
+if(WITH_STATIC_LIB)
+    target_include_directories(${name}_static ${ARGN})
+endif()
+
+endmacro(TARGET_INCLUDE_DIRECTORIES_THRIFT)
+
+
 macro(TARGET_LINK_LIBRARIES_THRIFT name)
 
 if(WITH_SHARED_LIB)
@@ -84,11 +95,11 @@
 macro(TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY target libname)
 
 if(WITH_SHARED_LIB)
-    target_link_libraries(${target} ${libname})
+    target_link_libraries(${target} ${ARGN} ${libname})
 endif()
 
 if(WITH_STATIC_LIB)
-    target_link_libraries(${target}_static ${libname}_static)
+    target_link_libraries(${target}_static ${ARGN} ${libname}_static)
 endif()
 
 endmacro(TARGET_LINK_LIBRARIES_THRIFT_AGAINST_THRIFT_LIBRARY)