THRIFT-5109 Misc Cmake build improvements
Patch: Mario Emmenlauer

This closes #2017
This closes #2018
This closes #2019

- build/cmake/DefineInstallationPaths.cmake: fixed the library path
- build/cmake/ThriftMacros.cmake: do not enforce debug suffix 'd'
- lib/java/CMakeLists.txt: allow to override JAVA_INSTALL_DIR
diff --git a/build/cmake/DefineInstallationPaths.cmake b/build/cmake/DefineInstallationPaths.cmake
index 0c824cc..23962b4 100644
--- a/build/cmake/DefineInstallationPaths.cmake
+++ b/build/cmake/DefineInstallationPaths.cmake
@@ -20,7 +20,11 @@
 
 # Define the default install paths
 set(BIN_INSTALL_DIR "bin" CACHE PATH "The binary install dir (default: bin)")
-set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The library install dir (default: lib${LIB_SUFFIX})")
+if(MSVC)
+    set(LIB_INSTALL_DIR "bin${LIB_SUFFIX}" CACHE PATH "The library install dir (default: bin${LIB_SUFFIX})")
+else()
+    set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "The library install dir (default: lib${LIB_SUFFIX})")
+endif()
 set(INCLUDE_INSTALL_DIR "include" CACHE PATH "The library install dir (default: include)")
 set(CMAKE_INSTALL_DIR "lib/cmake" CACHE PATH "The subdirectory to install cmake config files (default: cmake)")
 set(PKGCONFIG_INSTALL_DIR "lib/pkgconfig" CACHE PATH "The subdirectory to install pkgconfig config files (default: lib/pkgconfig)")
diff --git a/build/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake
index c0bb529..f43f503 100644
--- a/build/cmake/DefinePlatformSpecifc.cmake
+++ b/build/cmake/DefinePlatformSpecifc.cmake
@@ -20,8 +20,8 @@
 # Uncomment this to show some basic cmake variables about platforms
 # include (NewPlatformDebug)
 
-# For Debug build types, append a "d" to the library names.
-set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix" FORCE)
+# For Debug build types, default to "d"-suffix in library names.
+set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix")
 
 # basic options
 foreach(lang IN ITEMS C CXX)
diff --git a/lib/java/CMakeLists.txt b/lib/java/CMakeLists.txt
index a67845a..28158c0 100644
--- a/lib/java/CMakeLists.txt
+++ b/lib/java/CMakeLists.txt
@@ -29,11 +29,12 @@
     add_custom_target(thrift_aar ALL DEPENDS ${THRIFT_AAR})
 
 else()
-
-    if(IS_ABSOLUTE "${LIB_INSTALL_DIR}")
-        set(JAVA_INSTALL_DIR "${LIB_INSTALL_DIR}/java")
-    else()
-        set(JAVA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/java")
+    if(NOT JAVA_INSTALL_DIR)
+        if(IS_ABSOLUTE "${LIB_INSTALL_DIR}")
+            set(JAVA_INSTALL_DIR "${LIB_INSTALL_DIR}/java")
+        else()
+            set(JAVA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/java")
+        endif()
     endif()
 
     if(IS_ABSOLUTE "${DOC_INSTALL_DIR}")