THRIFT-3873: fix various compiler warnings and overflow errors
THRIFT-3847: change VERSION to PACKAGE_VERSION to avoid conflicts with third party or OS headers

This closes #1128
diff --git a/build/cmake/ConfigureChecks.cmake b/build/cmake/ConfigureChecks.cmake
index f650544..81223d8 100644
--- a/build/cmake/ConfigureChecks.cmake
+++ b/build/cmake/ConfigureChecks.cmake
@@ -17,17 +17,16 @@
 # under the License.
 #
 
-
-include(CheckSymbolExists)
+include(CheckFunctionExists)
 include(CheckIncludeFile)
 include(CheckIncludeFiles)
-include(CheckFunctionExists)
+include(CheckSymbolExists)
 
-# 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)
+if (Inttypes_FOUND)
+  # This allows the inttypes.h and stdint.h checks to succeed on platforms that
+  # do not natively provide there.
+  set (CMAKE_REQUIRED_INCLUDES ${INTTYPES_INCLUDE_DIRS})
+endif ()
 
 check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
 check_include_file(fcntl.h HAVE_FCNTL_H)
@@ -72,5 +71,5 @@
 
 # generate a config.h file
 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/build/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}")
+
+include_directories("${CMAKE_CURRENT_BINARY_DIR}")