Index: code/trunk/cmake/LibraryConfig.cmake
===================================================================
--- code/trunk/cmake/LibraryConfig.cmake	(revision 8411)
+++ code/trunk/cmake/LibraryConfig.cmake	(revision 8412)
@@ -129,4 +129,8 @@
   FIND_PACKAGE(DbgHelp)
   FIND_PACKAGE(DirectX       REQUIRED)
+  IF(MSVC)
+    # Check whether we can use Visual Leak Detector
+    FIND_PACKAGE(VLD QUIET)
+  ENDIF()
 ENDIF()
 
Index: code/trunk/cmake/tools/FindVLD.cmake
===================================================================
--- code/trunk/cmake/tools/FindVLD.cmake	(revision 8412)
+++ code/trunk/cmake/tools/FindVLD.cmake	(revision 8412)
@@ -0,0 +1,45 @@
+ #
+ #             ORXONOX - the hottest 3D action shooter ever to exist
+ #                             > www.orxonox.net <
+ #
+ #        This program is free software; you can redistribute it and/or
+ #         modify it under the terms of the GNU General Public License
+ #        as published by the Free Software Foundation; either version 2
+ #            of the License, or (at your option) any later version.
+ #
+ #       This program is distributed in the hope that it will be useful,
+ #        but WITHOUT ANY WARRANTY; without even the implied warranty of
+ #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ #                 GNU General Public License for more details.
+ #
+ #   You should have received a copy of the GNU General Public License along
+ #      with this program; if not, write to the Free Software Foundation,
+ #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ #
+ #
+ #  Author:
+ #    Reto Grieder
+ #  Description:
+ #    Finds the Visual Leak Detector if installed
+ #
+
+INCLUDE(FindPackageHandleStandardArgs)
+
+FIND_PATH(VLD_INCLUDE_DIR vld.h
+  PATH_SUFFIXES "Visual Leak Detector/include"
+)
+FIND_LIBRARY(VLD_LIBRARY
+  NAMES vld
+  PATH_SUFFIXES "Visual Leak Detector/lib/Win32"
+)
+
+# Handle the REQUIRED argument and set POCO_FOUND
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(VLD DEFAULT_MSG
+  VLD_LIBRARY
+  VLD_INCLUDE_DIR
+)
+
+MARK_AS_ADVANCED(
+  VLD_INCLUDE_DIR
+  VLD_LIBRARY
+)
Index: code/trunk/cmake/tools/TargetUtilities.cmake
===================================================================
--- code/trunk/cmake/tools/TargetUtilities.cmake	(revision 8411)
+++ code/trunk/cmake/tools/TargetUtilities.cmake	(revision 8412)
@@ -305,6 +305,6 @@
 
   # Visual Leak Detector specific stuff (avoids the include)
-  IF(HAVE_VLD)
-    TARGET_LINK_LIBRARIES(${_target_name} ${VLD_LIBRARY})
+  IF(VISUAL_LEAK_DETECTOR_ENABLE)
+    TARGET_LINK_LIBRARIES(${_target_name} debug ${VLD_LIBRARY})
   ENDIF()
 
Index: code/trunk/src/CMakeLists.txt
===================================================================
--- code/trunk/src/CMakeLists.txt	(revision 8411)
+++ code/trunk/src/CMakeLists.txt	(revision 8412)
@@ -54,4 +54,18 @@
   ADD_COMPILER_FLAGS("-DNTDDI_VERSION=0x05010000")
 ENDIF(WIN32)
+
+# Visual Leak Dectector configuration
+IF(MSVC AND VLD_FOUND)
+  OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" OFF)
+  IF(VISUAL_LEAK_DETECTOR_ENABLE)
+    # Force library linking by forcing the inclusion of a symbol
+    ADD_LINKER_FLAGS("-INCLUDE:__imp_?vld@@3VVisualLeakDetector@@A" Debug)
+    IF(MSVC90)
+      # VS 2008 incremental linker crashes with /INCLUDE most of the time
+      REMOVE_LINKER_FLAGS("-INCREMENTAL:YES" Debug)
+      ADD_LINKER_FLAGS   ("-INCREMENTAL:NO"  Debug)
+    ENDIF()
+  ENDIF()
+ENDIF()
 
 ######### Library Behaviour (external) ##########
@@ -110,4 +124,8 @@
 IF (DBGHELP_FOUND)
   INCLUDE_DIRECTORIES(${DBGHELP_INCLUDE_DIR})
+ENDIF()
+
+IF(VISUAL_LEAK_DETECTOR_ENABLE)
+  INCLUDE_DIRECTORIES(${VLD_INCLUDE_DIR})
 ENDIF()
 
Index: code/trunk/src/OrxonoxConfig.cmake
===================================================================
--- code/trunk/src/OrxonoxConfig.cmake	(revision 8411)
+++ code/trunk/src/OrxonoxConfig.cmake	(revision 8412)
@@ -80,24 +80,4 @@
 ADD_COMPILER_FLAGS("-DCMAKE_MinSizeRel_BUILD"     MinSizeRel)
 
-IF(MSVC)
-  # Check whether we can use Visual Leak Detector
-  FIND_FILE(VLD_DLL vld_x86.dll)
-  IF(VLD_DLL)
-    SET(HAVE_VLD TRUE)
-    OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" off)
-    # Make sure the value is "on" or "off" for vld.ini
-    IF(VISUAL_LEAK_DETECTOR_ENABLE)
-      SET(VISUAL_LEAK_DETECTOR_ENABLE on)
-    ELSE()
-      SET(VISUAL_LEAK_DETECTOR_ENABLE off)
-    ENDIF()
-    SET(VLD_LIBRARY vld.lib)
-    # Force symbol reference
-    # The alternative would be to include vld.h everywhere (includes windows.h)
-    ADD_LINKER_FLAGS("-INCLUDE:__imp_?vld@@3VVisualLeakDetector@@A" Debug)
-  ENDIF()
-  MARK_AS_ADVANCED(VLD_DLL)
-ENDIF()
-
 ############## Configured Headers ###############
 
