win32: Automatically check for DbgHelp availability

Nicolas Hake 2011-10-03 13:09:51 +02:00
parent 14f81d7eef
commit cc672bbd00
4 changed files with 43 additions and 11 deletions

View File

@ -58,12 +58,9 @@ if(WIN32)
else()
endif()
option(GENERATE_MINI_DUMP "Generate a minidump on crash" ON)
else()
SET(USE_DIRECTX OFF)
SET(HAVE_FMOD OFF)
SET(GENERATE_MINI_DUMP OFF)
endif()
if(NOT USE_GL AND NOT USE_DIRECTX)
message(STATUS "No graphics display enabled; building dedicated server")
@ -1108,11 +1105,13 @@ CHECK_INCLUDE_FILE_CXX(getopt.h HAVE_GETOPT_H)
add_subdirectory(thirdparty/tinyxml)
target_link_libraries(clonk tinyxml)
if(GENERATE_MINI_DUMP)
FIND_PATH(DBGHELP_INCLUDE_DIR NAMES dbghelp.h)
FINDLIB(DBGHELP_LIBRARIES NAMES dbghelp)
target_link_libraries(clonk ${DBGHELP_LIBRARIES})
include_directories(${DBGHELP_INCLUDE_DIR})
if(WIN32)
find_package(DbgHelp)
if(DBGHELP_FOUND)
target_link_libraries(clonk ${DBGHELP_LIBRARIES})
include_directories(${DBGHELP_INCLUDE_DIR})
endif()
set(HAVE_DBGHELP ${DBGHELP_FOUND})
endif()
if(USE_GL)

View File

@ -0,0 +1,33 @@
# - Find DbgHelp
# Find the DbgHelp library
# This module defines
# DBGHELP_INCLUDE_DIR, where to find dbghelp.h, etc.
# DBGHELP_LIBRARIES, the libraries needed to use DbgHelp.
# DBGHELP_FOUND, If false, do not try to use DbgHelp.
#=============================================================================
# OpenClonk, http://www.openclonk.org
#
# Copyright (c) 2011 Nicolas Hake
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# See isc_license.txt for full license and disclaimer.
#
# "Clonk" is a registered trademark of Matthes Bender.
# See clonk_trademark_license.txt for full license.
#=============================================================================
find_path(DBGHELP_INCLUDE_DIR NAMES dbghelp.h)
set(DBGHELP_NAMES ${DBGHELP_NAMES} dbghelp)
find_library(DBGHELP_LIBRARY NAMES ${DBGHELP_NAMES})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DBGHELP DEFAULT_MSG DBGHELP_LIBRARY DBGHELP_INCLUDE_DIR)
if(DBGHELP_FOUND)
set(DBGHELP_LIBRARIES ${DBGHELP_LIBRARY})
endif()
mark_as_advanced(DBGHELP_LIBRARY DBGHELP_INCLUDE_DIR)

View File

@ -209,4 +209,4 @@
#cmakedefine HAVE_STATIC_ASSERT 1
/* Generate minidumps on crash */
#cmakedefine GENERATE_MINI_DUMP 1
#cmakedefine HAVE_DBGHELP 1

View File

@ -27,7 +27,7 @@
#include "C4Include.h"
#ifdef GENERATE_MINI_DUMP
#ifdef HAVE_DBGHELP
// Dump generation on crash
#include <C4windowswrapper.h>
@ -527,4 +527,4 @@ void InstallCrashHandler()
// no-op
}
#endif // GENERATE_MINI_DUMP
#endif // HAVE_DBGHELP