From 29912bd494152112cedd1afaf83196ae4e5919be Mon Sep 17 00:00:00 2001
From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com>
Date: Sun, 23 Jul 2023 14:21:19 -0400
Subject: [PATCH] Update README installation and usage instructions and fix a
cmake issue
---
CMakeLists.txt | 22 +++++++++++----------
README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 62 insertions(+), 12 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d69bac9..698c5f0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ target_include_directories(
cpptrace
PUBLIC
$
- $
+ $
)
# TODO
@@ -102,16 +102,18 @@ function(check_support var source includes libraries definitions)
set(${var} ${${var}} PARENT_SCOPE)
endfunction()
-check_support(HAS_UNWIND has_unwind.cpp "" "" "")
-check_support(HAS_EXECINFO has_execinfo.cpp "" "" "")
-check_support(HAS_BACKTRACE has_backtrace.cpp "" "backtrace" "${CPPTRACE_BACKTRACE_PATH_DEFINITION}")
-check_support(HAS_CXXABI has_cxxabi.cpp "" "" "")
-if(NOT MSVC)
- set(STACKTRACE_LINK_LIB "stdc++_libbacktrace")
-else()
- set(STACKTRACE_LINK_LIB "")
+if(NOT MSVC) # No need to bother checking in msvc, but do check in minngw
+ check_support(HAS_UNWIND has_unwind.cpp "" "" "")
+ check_support(HAS_EXECINFO has_execinfo.cpp "" "" "")
+ check_support(HAS_BACKTRACE has_backtrace.cpp "" "backtrace" "${CPPTRACE_BACKTRACE_PATH_DEFINITION}")
+ check_support(HAS_CXXABI has_cxxabi.cpp "" "" "")
+ if(NOT MSVC)
+ set(STACKTRACE_LINK_LIB "stdc++_libbacktrace")
+ else()
+ set(STACKTRACE_LINK_LIB "")
+ endif()
+ check_support(HAS_STACKTRACE has_stacktrace.cpp "" "${STACKTRACE_LINK_LIB}" "")
endif()
-check_support(HAS_STACKTRACE has_stacktrace.cpp "" "${STACKTRACE_LINK_LIB}" "")
# =============================================== Autoconfig full dump ===============================================
# If nothing is specified, attempt to use libbacktrace's full dump
diff --git a/README.md b/README.md
index 80e8e46..cd89ade 100644
--- a/README.md
+++ b/README.md
@@ -45,6 +45,8 @@ target_link_libraries(your_target PRIVATE cpptrace)
It's as easy as that. Cpptrace will automatically configure itself for your system.
+Be sure to configure with `-DCMAKE_BUILD_TYPE=Debug`.
+

## Other Installation Mechanisms
@@ -57,12 +59,33 @@ git clone https://github.com/jeremy-rifkin/cpptrace.git
mkdir cpptrace/build
cd cpptrace/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On
-make
+make -j
sudo make install
```
+Using through cmake:
+```cmake
+include(CMakeFindDependencyMacro)
+find_dependency(cpptrace REQUIRED)
+target_link_libraries( cpptrace)
+```
+Be sure to configure with `-DCMAKE_BUILD_TYPE=Debug`.
+
+Or compile with `-lcpptrace`:
+
+```sh
+g++ main.cpp -o main -g -Wall -lcpptrace
+./main
+```
+
+If you get an error along the lines of
+```
+error while loading shared libraries: libcpptrace.so: cannot open shared object file: No such file or directory
+```
+You may have to run `sudo /sbin/ldconfig` so the system finds libcpptrace.so (I had to do this on Ubuntu).
+
- Or on windows
+ System-wide install on windows
```ps1
git clone https://github.com/jeremy-rifkin/cpptrace.git
@@ -78,6 +101,31 @@ Note: You'll need to run as an administrator in a developer powershell, or use v
studio to get the correct environment variables set.
+### Local User Installation
+
+To install just for the local user (or any custom prefix):
+
+```sh
+git clone https://github.com/jeremy-rifkin/cpptrace.git
+# optional: git checkout
+mkdir cpptrace/build
+cd cpptrace/build
+cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On -DCMAKE_INSTALL_PREFIX=$HOME/wherever
+make -j
+sudo make install
+```
+
+Using through cmake:
+```cmake
+find_package(cpptrace REQUIRED PATHS $ENV{HOME}/wherever)
+target_link_libraries( cpptrace::cpptrace)
+```
+
+Using manually:
+```
+g++ main.cpp -o main -g -Wall -I$HOME/wherever/include -L$HOME/wherever/lib -lcpptrace
+```
+
### Package Managers
TODO