diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36244dd450cb5a78ae21f9464c6f1c38d8d8ba4c..5e13a7e0f4632816914fd33d1c37b887ce4526da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -144,17 +144,6 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
 
 endmacro()
 
-
-
-
-if(NOT CMake_TEST_EXTERNAL_CMAKE)
-  set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
-  if(WIN32 AND NOT UNIX AND NOT MINGW)
-    set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
-  endif()
-endif()
-
-
 #-----------------------------------------------------------------------
 # a macro to determine the generator and ctest executable to use
 # for testing. Simply to improve readability of the main script.
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 428b3648da3832fc23e36dddec43a5e876ccd681..1886519cf078e9ffe69c4adb585cec115906f8cd 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -556,8 +556,8 @@ if(APPLE)
   target_link_libraries(CMakeLib "-framework CoreFoundation")
 endif()
 
-if(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW)
-  # We need the rpcrt4 library for at least the VS7-VC10 generators.
+if(WIN32 AND NOT UNIX)
+  # We need the rpcrt4 library on Windows.
   target_link_libraries(CMakeLib rpcrt4)
 endif()