Skip to content

Commit

Permalink
Merge pull request #234 from madebr/mingw
Browse files Browse the repository at this point in the history
Build backward-cpp on MINGW
  • Loading branch information
bombela authored Aug 12, 2021
2 parents bd93894 + 146e2ed commit 3bb9240
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions BackwardConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ if (NOT _BACKWARD_DEFINITIONS)
map_definitions("STACK_DETAILS_" "BACKWARD_HAS_" BACKTRACE_SYMBOL DW BFD DWARF)
endif()

if(WIN32)
list(APPEND _BACKWARD_LIBRARIES dbghelp psapi)
if(MINGW)
set(MINGW_MSVCR_LIBRARY "msvcr90$<$<CONFIG:DEBUG>:d>" CACHE STRING "Mingw MSVC runtime import library")
list(APPEND _BACKWARD_LIBRARIES ${MINGW_MSVCR_LIBRARY})
endif()
endif()

set(BACKWARD_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}")

set(BACKWARD_HAS_EXTERNAL_LIBRARIES FALSE)
Expand Down
4 changes: 4 additions & 0 deletions backward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@
#include <basetsd.h>
typedef SSIZE_T ssize_t;

#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#include <winnt.h>

Expand All @@ -352,8 +354,10 @@ typedef SSIZE_T ssize_t;
#define NOINLINE __declspec(noinline)
#endif

#ifdef _MSC_VER
#pragma comment(lib, "psapi.lib")
#pragma comment(lib, "dbghelp.lib")
#endif

// Comment / packing is from stackoverflow:
// https://stackoverflow.com/questions/6205981/windows-c-stack-trace-from-a-running-app/28276227#28276227
Expand Down
2 changes: 1 addition & 1 deletion test/_test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <cstdlib>

#ifdef _WIN32
#include <Windows.h>
#include <windows.h>
#define strcasecmp _stricmp
#else
#include <sys/wait.h>
Expand Down

0 comments on commit 3bb9240

Please sign in to comment.