From e80d447ad2eb9d5e2201312039524cd810de16ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20K=C3=BCmmel?= Date: Sun, 2 Dec 2007 11:17:01 +0000 Subject: [PATCH] vld LyX/cmake integration git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21912 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/Win32/vld/include/vld.h | 7 +- .../Win32/vld/tools/cmake/CMakeLists.txt | 53 ++++ development/Win32/vld/tools/cmake/vld.cmake | 31 +++ .../Win32/vld/tools/msvc2005/vld.vcproj | 250 ++++++++++++++++++ development/cmake/CMakeLists.txt | 17 ++ development/cmake/src/CMakeLists.txt | 10 +- 6 files changed, 366 insertions(+), 2 deletions(-) create mode 100644 development/Win32/vld/tools/cmake/CMakeLists.txt create mode 100644 development/Win32/vld/tools/cmake/vld.cmake create mode 100644 development/Win32/vld/tools/msvc2005/vld.vcproj diff --git a/development/Win32/vld/include/vld.h b/development/Win32/vld/include/vld.h index db136ced53..66af3f0639 100644 --- a/development/Win32/vld/include/vld.h +++ b/development/Win32/vld/include/vld.h @@ -24,6 +24,8 @@ #pragma once +#ifndef VLD_BUILD + #ifdef _DEBUG #pragma comment(lib, "vld.lib") @@ -95,4 +97,7 @@ __declspec(dllimport) void VLDEnable (); #define VLDEnable() #define VLDDisable() -#endif // _DEBUG \ No newline at end of file +#endif // _DEBUG + +#endif //VLD_BUILD + diff --git a/development/Win32/vld/tools/cmake/CMakeLists.txt b/development/Win32/vld/tools/cmake/CMakeLists.txt new file mode 100644 index 0000000000..aef88319fb --- /dev/null +++ b/development/Win32/vld/tools/cmake/CMakeLists.txt @@ -0,0 +1,53 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// Visual Leak Detector - CallStack Class Implementations +// Copyright (c) 2005-2006 Dan Moulding +// Copyright (c) 2007 Peter Kümmel, CMake files +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// +// See COPYING.txt for the full terms of the GNU Lesser General Public License. +// +//////////////////////////////////////////////////////////////////////////////// + +project(vld) + +include(CheckCXXSourceCompiles) + +check_cxx_source_compiles( + " + #pragma comment(lib, \"dbghelp.lib\") + #define UNICODE + #define _UNICODE + #include + #include + int main(){void* ptr = (void*)&SymInitializeW; return 0;} + " +HAVE_DEBUGGING_TOOLS_FOR_WINDOWS) + +if (NOT HAVE_DEBUGGING_TOOLS_FOR_WINDOWS) + message(STATUS "'Debugging Tools for Windows' not found.") + message(STATUS "Please install the tools from http://www.microsoft.com/whdc/devtools/debugging/default.mspx") + message(STATUS "and add it to the Visual Studio include and lib serach paths.") + message(FATAL_ERROR "") +endif (NOT HAVE_DEBUGGING_TOOLS_FOR_WINDOWS) + +file(GLOB vld_sources ${vld_path}/src/*.cpp) +file(GLOB vld_headers ${vld_path}/src/*.h) + +add_definitions(-DVLD_BUILD -DUNICODE -D_UNICODE) + +add_library(vld SHARED ${vld_sources} ${vld_headers} ${vld_path}/include/vld.h) + diff --git a/development/Win32/vld/tools/cmake/vld.cmake b/development/Win32/vld/tools/cmake/vld.cmake new file mode 100644 index 0000000000..182f78e09e --- /dev/null +++ b/development/Win32/vld/tools/cmake/vld.cmake @@ -0,0 +1,31 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// Visual Leak Detector - CallStack Class Implementations +// Copyright (c) 2005-2006 Dan Moulding +// Copyright (c) 2007 Peter Kümmel, CMake files +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// +// See COPYING.txt for the full terms of the GNU Lesser General Public License. +// +//////////////////////////////////////////////////////////////////////////////// + +# This triggers the useage of vld in all other projects +include_directories(${vld_path}/include) +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /FIvld.h") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /FIvld.h") +set(vld_dll vld) + +add_subdirectory(${vld_path}/tools/cmake ${CMAKE_BINARY_DIR}/vld) diff --git a/development/Win32/vld/tools/msvc2005/vld.vcproj b/development/Win32/vld/tools/msvc2005/vld.vcproj new file mode 100644 index 0000000000..1f42d6bb39 --- /dev/null +++ b/development/Win32/vld/tools/msvc2005/vld.vcproj @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/development/cmake/CMakeLists.txt b/development/cmake/CMakeLists.txt index dfaa86428f..bbd10f6840 100644 --- a/development/cmake/CMakeLists.txt +++ b/development/cmake/CMakeLists.txt @@ -206,6 +206,23 @@ else() endif() if(MSVC) + if(vld) + set(vld 1 CACHE TYPE STRING FORCE) + set(LYX_LEAK_DETECTION 1 CACHE TYPE STRING FORCE) + message(STATUS "") + message(STATUS "Leak detection enabled, disable with -Dvld=0") + message(STATUS "") + set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) + set(vld_path ${CMAKE_CURRENT_SOURCE_DIR}/../Win32/vld) + include(${vld_path}/tools/cmake/vld.cmake) + else() + set(vld 0 CACHE TYPE STRING FORCE) + set(LYX_LEAK_DETECTION 0 CACHE TYPE STRING FORCE) + message(STATUS "") + message(STATUS "Enable leak detection with -Dvld=1") + message(STATUS "") + endif() + if(WALL) set(WALL 1 CACHE TYPE STRING FORCE) diff --git a/development/cmake/src/CMakeLists.txt b/development/cmake/src/CMakeLists.txt index 5efceab267..271a738bd4 100644 --- a/development/cmake/src/CMakeLists.txt +++ b/development/cmake/src/CMakeLists.txt @@ -44,10 +44,17 @@ else() set(lyx_sources ${_allinone_files}) endif() +if(LYX_LEAK_DETECTION) + configure_file(${vld_path}/vld.ini ${CMAKE_CURRENT_BINARY_DIR}/vld.ini COPYONLY) + configure_file(${vld_path}/vld.ini ${CMAKE_CURRENT_BINARY_DIR}/memory_leak_report.txt COPYONLY) + set(vld_files ${CMAKE_CURRENT_BINARY_DIR}/vld.ini ${CMAKE_CURRENT_BINARY_DIR}/memory_leak_report.txt) +endif() + add_executable(lyx ${WIN32_CONSOLE} ${lyx_sources} ${lyx_headers} + ${vld_files} ) target_link_libraries(lyx @@ -58,7 +65,8 @@ target_link_libraries(lyx graphics support intl - ${QT_QTMAIN_LIBRARY}) + ${QT_QTMAIN_LIBRARY} + ${vld_dll}) if(ASPELL_FOUND) target_link_libraries(lyx ${ASPELL_LIBRARY}) -- 2.39.5