Permalink
Browse files

cmake: Add feature test for crtdbg.h.

  • Loading branch information...
1 parent c39f725 commit 21d3f3c86fce2a27a2b6c13d31006e271db1b80f @BloodyRabbit BloodyRabbit committed May 19, 2012
Showing with 21 additions and 9 deletions.
  1. +1 −0 CMakeLists.txt
  2. +4 −0 config.h.in
  3. +10 −3 include/common/common.h
  4. +2 −2 src/eve-server/main.cpp
  5. +2 −2 src/eve-tool/main.cpp
  6. +2 −2 src/xmlpktgen/main.cpp
View
@@ -38,6 +38,7 @@ INCLUDE( "TestX64" )
TEST_X64( X64 )
SET( GNUC ${CMAKE_COMPILER_IS_GNUCXX} )
+CHECK_INCLUDE_FILE( "crtdbg.h" HAVE_CRTDBG_H )
CHECK_INCLUDE_FILE( "inttypes.h" HAVE_INTTYPES_H )
CHECK_CXX_SYMBOL_EXISTS( __FreeBSD__ "" FREE_BSD )
View
@@ -44,6 +44,10 @@
/* Feature defines */
/*************************************************************************/
+// HAVE_CRTDBG_H
+// Define if crtdbg.h is available.
+#cmakedefine HAVE_CRTDBG_H 1
+
// HAVE_INTTYPES_H
// Define if inttypes.h is available.
#cmakedefine HAVE_INTTYPES_H 1
View
@@ -49,10 +49,13 @@
# define _CRT_SECURE_NO_WARNINGS 1
# define _CRT_SECURE_NO_DEPRECATE 1
# define _CRT_SECURE_COPP_OVERLOAD_STANDARD_NAMES 1
-# define _CRTDBG_MAP_ALLOC 1
# define _SCL_SECURE_NO_WARNINGS 1
#endif /* _MSC_VER */
+#ifdef HAVE_CRTDBG_H
+# define _CRTDBG_MAP_ALLOC 1
+#endif /* HAVE_CRTDBG_H */
+
// We must "explicitly request" the format strings ...
#ifdef HAVE_INTTYPES_H
# define __STDC_FORMAT_MACROS 1
@@ -124,6 +127,12 @@
#endif /* !WIN32 */
// Feature includes
+#ifdef HAVE_CRTDBG_H
+# include <crtdbg.h>
+ // This is necessary to track leaks introduced by operator new()
+# define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
+#endif /* HAVE_CRTDBG_H */
+
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif /* HAVE_INTTYPES_H */
@@ -142,9 +151,7 @@
// Visual Studio memory leak detection includes
#ifdef MSVC
# ifndef NDEBUG
-# include <crtdbg.h>
//# include <vld.h> // Only enable if you have VLD installed
-//# define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
# endif /* !NDEBUG */
#endif /* MSVC */
View
@@ -38,10 +38,10 @@ dgmtypeattributemgr * _sDgmTypeAttrMgr;
int main( int argc, char* argv[] )
{
-#if defined( MSVC ) && !defined( NDEBUG )
+#if defined( HAVE_CRTDBG_H ) && !defined( NDEBUG )
// Under Visual Studio setup memory leak detection
_CrtSetDbgFlag( _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) );
-#endif /* defined( MSVC ) && !defined( NDEBUG ) */
+#endif /* defined( HAVE_CRTDBG_H ) && !defined( NDEBUG ) */
printf("Copyright (C) 2006-2011 EVEmu Team. http://evemu.org/\n");
printf("This program is free software; you can redistribute it and/or modify it under\n");
View
@@ -34,10 +34,10 @@ const char* const LOG_SETTINGS_FILE = EVEMU_ROOT "/etc/log.ini";
int main( int argc, char* argv[] )
{
-#if defined( MSVC ) && !defined( NDEBUG )
+#if defined( HAVE_CRTDBG_H ) && !defined( NDEBUG )
// Under Visual Studio setup memory leak detection
_CrtSetDbgFlag( _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) );
-#endif /* defined( MSVC ) && !defined( NDEBUG ) */
+#endif /* defined( HAVE_CRTDBG_H ) && !defined( NDEBUG ) */
// Load server log settings ( will be removed )
if( !load_log_settings( LOG_SETTINGS_FILE ) )
View
@@ -31,10 +31,10 @@ void usage();
int main( int argc, char* argv[] )
{
-#if defined( MSVC ) && !defined( NDEBUG )
+#if defined( HAVE_CRTDBG_H ) && !defined( NDEBUG )
// Under Visual Studio setup memory leak detection
_CrtSetDbgFlag( _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) );
-#endif /* defined( MSVC ) && !defined( NDEBUG ) */
+#endif /* defined( HAVE_CRTDBG_H ) && !defined( NDEBUG ) */
// skip first argument, not interested
--argc;

0 comments on commit 21d3f3c

Please sign in to comment.