From ea6e24200c4cb8fd5d928debdbfa3ba93eb0ec59 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 26 Aug 2013 15:28:59 +0200 Subject: [PATCH] Allow the use of Visual Leak Detector See the small feature [[Small features/Visual_Leak_Detector]] in CGAL developers wiki: https://cgal.geometryfactory.com/CGAL/Members/wiki/Features/Small_Features/Visual_Leak_Detector See also: http://vld.codeplex.com/ --- Installation/cmake/modules/CGAL_Common.cmake | 9 +++++ .../cmake/modules/CGAL_SetupVLD.cmake | 37 +++++++++++++++++++ Installation/include/CGAL/config.h | 9 ++++- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 Installation/cmake/modules/CGAL_SetupVLD.cmake diff --git a/Installation/cmake/modules/CGAL_Common.cmake b/Installation/cmake/modules/CGAL_Common.cmake index 9bcceb006f1..adbb899c9a7 100644 --- a/Installation/cmake/modules/CGAL_Common.cmake +++ b/Installation/cmake/modules/CGAL_Common.cmake @@ -50,6 +50,15 @@ if( NOT CGAL_COMMON_FILE_INCLUDED ) endif() endif() hide_variable(CMAKE_UNAME) + + # Optionally setup the Visual Leak Detector + include(CGAL_SetupVLD) + CGAL_SetupVLD() + if(VLD_FOUND) + message(STATUS "Visual Leak Detector (VLD) is enabled.") + else() + message(STATUS "Visual Leak Detector (VLD) is not found.") + endif() endif() set(CMAKE_COLORMAKEFILE ON) diff --git a/Installation/cmake/modules/CGAL_SetupVLD.cmake b/Installation/cmake/modules/CGAL_SetupVLD.cmake new file mode 100644 index 00000000000..c3ed7d23a2f --- /dev/null +++ b/Installation/cmake/modules/CGAL_SetupVLD.cmake @@ -0,0 +1,37 @@ +function(CGAL_setupVLD) + + if(DEFINED ENV{CGAL_ENABLE_VLD} AND NOT DEFINED CGAL_ENABLE_VLD) + set(CGAL_ENABLE_VLD $ENV{CGAL_ENABLE_VLD}) + endif() + + if(CGAL_ENABLE_VLD) + find_path(VLD_INCLUDE_DIR vld.h + HINTS $ENV{VLD_INCLUDE_DIR} + $ENV{VLD_HOME}/include + $ENV{VLD_HOME} + DOC "Path of the Visual Leak Detector header vld.h" + ) + + find_library(VLD_LIBRARY + NAMES vld-x86 vld + HINTS ${VLD_LIBRARY_DIR} + $ENV{VLD_LIBRARY_DIR} + $ENV{VLD_HOME}/lib + $ENV{VLD_HOME} + ${VLD_INCLUDE_DIR} + ${VLD_INCLUDE_DIR}/lib + DOC "Path of the Visual Leak Detector library vld.lib" + ) + if(VLD_LIBRARY) + get_filename_component(VLD_LIBRARY_DIR "${VLD_LIBRARY}" PATH CACHE) + endif() + + if(VLD_INCLUDE_DIR AND VLD_LIBRARY_DIR) + set(VLD_FOUND 1 PARENT_SCOPE) + include_directories(${VLD_INCLUDE_DIR}) + link_directories(${VLD_LIBRARY_DIR}) + add_definitions(-DCGAL_ENABLE_VLD) + endif() + + endif(CGAL_ENABLE_VLD) +endfunction() diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index b2a42c7e455..d4bf55ae649 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -1,4 +1,4 @@ -// Copyright (c) 1997-2010 +// Copyright (c) 1997-2013 // Utrecht University (The Netherlands), // ETH Zurich (Switzerland), // INRIA Sophia-Antipolis (France), @@ -23,6 +23,7 @@ // Author(s) : Wieger Wesselink // Michael Hoffmann // Sylvain Pion +// Laurent Rineau #ifndef CGAL_CONFIG_H #define CGAL_CONFIG_H @@ -43,6 +44,12 @@ # error The test-suite needs no NDEBUG defined #endif // CGAL_TEST_SUITE and NDEBUG +// See [[Small features/Visual_Leak_Detector]] in CGAL developers wiki +// See also: http://vld.codeplex.com/ +#if defined(CGAL_ENABLE_VLD) +# include +#endif // CGAL_ENABLE_VLD + // Workaround to the following bug: // https://bugreports.qt.nokia.com/browse/QTBUG-22829 #ifdef Q_MOC_RUN