Update README installation and usage instructions and fix a cmake issue

This commit is contained in:
Jeremy 2023-07-23 14:21:19 -04:00
parent 55b5d8a488
commit 29912bd494
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4
2 changed files with 62 additions and 12 deletions

View File

@ -25,7 +25,7 @@ target_include_directories(
cpptrace cpptrace
PUBLIC PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpptrace/cpptrace> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpptrace/>
) )
# TODO # TODO
@ -102,6 +102,7 @@ function(check_support var source includes libraries definitions)
set(${var} ${${var}} PARENT_SCOPE) set(${var} ${${var}} PARENT_SCOPE)
endfunction() endfunction()
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_UNWIND has_unwind.cpp "" "" "")
check_support(HAS_EXECINFO has_execinfo.cpp "" "" "") check_support(HAS_EXECINFO has_execinfo.cpp "" "" "")
check_support(HAS_BACKTRACE has_backtrace.cpp "" "backtrace" "${CPPTRACE_BACKTRACE_PATH_DEFINITION}") check_support(HAS_BACKTRACE has_backtrace.cpp "" "backtrace" "${CPPTRACE_BACKTRACE_PATH_DEFINITION}")
@ -112,6 +113,7 @@ else()
set(STACKTRACE_LINK_LIB "") set(STACKTRACE_LINK_LIB "")
endif() endif()
check_support(HAS_STACKTRACE has_stacktrace.cpp "" "${STACKTRACE_LINK_LIB}" "") check_support(HAS_STACKTRACE has_stacktrace.cpp "" "${STACKTRACE_LINK_LIB}" "")
endif()
# =============================================== Autoconfig full dump =============================================== # =============================================== Autoconfig full dump ===============================================
# If nothing is specified, attempt to use libbacktrace's full dump # If nothing is specified, attempt to use libbacktrace's full dump

View File

@ -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. It's as easy as that. Cpptrace will automatically configure itself for your system.
Be sure to configure with `-DCMAKE_BUILD_TYPE=Debug`.
![Screenshot](res/screenshot.png) ![Screenshot](res/screenshot.png)
## Other Installation Mechanisms ## Other Installation Mechanisms
@ -57,12 +59,33 @@ git clone https://github.com/jeremy-rifkin/cpptrace.git
mkdir cpptrace/build mkdir cpptrace/build
cd cpptrace/build cd cpptrace/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=On
make make -j
sudo make install sudo make install
``` ```
Using through cmake:
```cmake
include(CMakeFindDependencyMacro)
find_dependency(cpptrace REQUIRED)
target_link_libraries(<your target> 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).
<details> <details>
<summary>Or on windows</summary> <summary>System-wide install on windows</summary>
```ps1 ```ps1
git clone https://github.com/jeremy-rifkin/cpptrace.git 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. studio to get the correct environment variables set.
</details> </details>
### 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 <HASH or TAG>
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(<your target> cpptrace::cpptrace)
```
Using manually:
```
g++ main.cpp -o main -g -Wall -I$HOME/wherever/include -L$HOME/wherever/lib -lcpptrace
```
### Package Managers ### Package Managers
TODO TODO