Fix BUILD_STATIC on MinGW and document the feature


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4683 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/BUILDING.txt b/BUILDING.txt
index c33ddc6..c497524 100644
--- a/BUILDING.txt
+++ b/BUILDING.txt
@@ -211,8 +211,8 @@
 build configuration or module dependencies.
 
 
-Building the TigerVNC Viewer/Server with Visual C++ (Command Line)
-------------------------------------------------------------------
+Building the Windows TigerVNC Viewer/Server with Visual C++ (Command Line)
+--------------------------------------------------------------------------
 
   cd {build_directory}
   cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release [additional CMake flags] {source_directory}
@@ -222,8 +222,8 @@
 on which version of cl.exe is in the PATH.
 
 
-Building the TigerVNC Viewer/Server with Visual C++ (IDE)
----------------------------------------------------------
+Building the Windows TigerVNC Viewer/Server with Visual C++ (IDE)
+-----------------------------------------------------------------
 
 Choose the appropriate CMake generator option for your version of Visual Studio
 (run "cmake" with no arguments for a list of available generators.)  For
@@ -237,8 +237,8 @@
 build of TigerVNC.
 
 
-Building the TigerVNC Viewer with MinGW
----------------------------------------
+Building the Windows TigerVNC Viewer with MinGW
+-----------------------------------------------
 
   cd {build_directory}
   cmake -G "MSYS Makefiles" [additional CMake flags] {source_directory}
@@ -256,13 +256,13 @@
 NMake.)
 
 
-Self-Contained MinGW Build
---------------------------
+Self-Contained GCC Build
+------------------------
 
-If TigerVNC is built using MinGW, then it may depend on the MinGW libgcc DLL.
-To eliminate this dependency, add
+If TigerVNC is built using GCC (including MinGW), then it may depend on the
+libgcc or libstdc++ dynamic libraries.  To eliminate this dependency, add
 
-  -DCMAKE_C_FLAGS=-static-libgcc -DCMAKE_CXX_FLAGS=-static-libgcc
+  -DBUILD_STATIC=1
 
 to the CMake command line.
 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3cee4a6..e330dc6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -134,14 +134,19 @@
       file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/staticlib)
       execute_process(COMMAND ${CMAKE_COMMAND} -E remove
         ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
-      execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
-        ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
+      if(MINGW)
+        execute_process(COMMAND ${CMAKE_COMMAND} -E copy
+          ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
+      else()
+        execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+          ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
+      endif()
       set(CMAKE_EXE_LINKER_FLAGS
         "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
       set(CMAKE_SHARED_LINKER_FLAGS
         "${CMAKE_SHARED_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
     else()
-      message(WARNING Cannot find static libstdc++.  VirtualGL will depend on dynamic libstdc++.)
+      message(WARNING Cannot find static libstdc++.  TigerVNC will depend on dynamic libstdc++.)
     endif()
     add_definitions(-static-libgcc)
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")