Skip to content

Commit

Permalink
build: Add CMakeLists.txt for cmake build
Browse files Browse the repository at this point in the history
This patch adds cmake build support and basic usages are as follows.

  $ cmake -B out
  $ make -C out

If you want to change the depth of stacktrace, then DEPTH variable can
be provided as follows.

  $ cmake -B out -DDEPTH=32
  $ make -C out

If DEPTH is not given, then the default depth is 8 as written in
CMakeLists.txt.

We don't remove the existing Make build until we're sure that cmake
looks stable enough.

Signed-off-by: Honggyu Kim <[email protected]>
  • Loading branch information
honggyukim committed Mar 19, 2023
1 parent 9cc0413 commit 7638841
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ heaptrace
*.out
*.patch
*.swp
CMake*
cmake_install.cmake
compile_commands.json
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ repos:
rev: v14.0.6
hooks:
- id: clang-format
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- id: cmake-lint
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-License-Identifier: GPL-2.0

cmake_minimum_required(VERSION 3.10)

project(heaptrace)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_compile_options("-Wno-psabi")

if(NOT DEFINED DEPTH)
set(DEPTH 8)
endif(NOT DEFINED DEPTH)
add_compile_definitions(DEPTH=${DEPTH})

add_library(libheaptrace SHARED src/libheaptrace.cc src/stacktrace.cc
src/sighandler.cc src/utils.cc)
set_property(TARGET libheaptrace PROPERTY OUTPUT_NAME heaptrace)

add_executable(heaptrace src/heaptrace.cc)

0 comments on commit 7638841

Please sign in to comment.