File tree 6 files changed +39
-1
lines changed
6 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 4
4
[submodule "3rdparty/googletest "]
5
5
path = 3rdparty/googletest
6
6
url = https://github.com/google/googletest.git
7
+ [submodule "3rdparty/cpptrace "]
8
+ path = 3rdparty/cpptrace
9
+ url = https://github.com/jeremy-rifkin/cpptrace.git
Original file line number Diff line number Diff line change @@ -15,7 +15,11 @@ else()
15
15
endif ()
16
16
17
17
option (XGRAMMAR_BUILD_PYTHON_BINDINGS "Build Python bindings" ON )
18
- option (XGRAMMAR_BUILD_CXX_TESTS "Build C++ tests" ON )
18
+ option (XGRAMMAR_BUILD_CXX_TESTS "Build C++ tests" OFF )
19
+ option (XGRAMMAR_ENABLE_CPPTRACE
20
+ "Enable C++ trace (Now only support Linux, and RelWithDebugInfo or Debug build)" OFF
21
+ )
22
+
19
23
set (XGRAMMAR_CUDA_ARCHITECTURES
20
24
native
21
25
CACHE STRING "CUDA architectures"
@@ -61,6 +65,12 @@ list(FILTER XGRAMMAR_SOURCES_PATH EXCLUDE REGEX "${PROJECT_SOURCE_DIR}/cpp/pybin
61
65
add_library (xgrammar STATIC ${XGRAMMAR_SOURCES_PATH} )
62
66
target_include_directories (xgrammar PUBLIC ${XGRAMMAR_INCLUDE_PATH} )
63
67
68
+ # link to cpptrace
69
+ if (XGRAMMAR_ENABLE_CPPTRACE)
70
+ add_subdirectory (${PROJECT_SOURCE_DIR} /3rdparty/cpptrace)
71
+ target_link_libraries (xgrammar PUBLIC cpptrace::cpptrace)
72
+ endif ()
73
+
64
74
if (XGRAMMAR_BUILD_PYTHON_BINDINGS)
65
75
add_subdirectory (${PROJECT_SOURCE_DIR} /cpp/pybind)
66
76
endif ()
Original file line number Diff line number Diff line change 1
1
set (CMAKE_BUILD_TYPE RelWithDebInfo)
2
2
set (XGRAMMAR_BUILD_PYTHON_BINDINGS ON )
3
3
set (XGRAMMAR_BUILD_CXX_TESTS OFF )
4
+ set (XGRAMMAR_ENABLE_CPPTRACE OFF )
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ file(GLOB_RECURSE XGRAMMAR_BINDINGS_PATH ${PROJECT_SOURCE_DIR}/cpp/*.cc)
21
21
pybind11_add_module(xgrammar_bindings ${XGRAMMAR_BINDINGS_PATH} )
22
22
target_include_directories (xgrammar_bindings PUBLIC ${XGRAMMAR_INCLUDE_PATH} )
23
23
24
+ if (XGRAMMAR_ENABLE_CPPTRACE)
25
+ target_link_libraries (xgrammar_bindings PUBLIC cpptrace::cpptrace)
26
+ endif ()
27
+
24
28
set (LIB_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR} /python/xgrammar" )
25
29
set_target_properties (xgrammar_bindings PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIRECTORY} )
26
30
set_target_properties (
Original file line number Diff line number Diff line change
1
+ /* !
2
+ * Copyright (c) 2024 by Contributors
3
+ * \file xgrammar/support/cpptrace.h
4
+ * \details This file is an encapsulation of the cpptrace library. It helps debugging. This file
5
+ * can only be included when XGRAMMAR_ENABLE_CPPTRACE is set to ON, and only support Linux and
6
+ * RelWithDebugInfo or Debug build.
7
+ */
8
+ #ifndef XGRAMMAR_SUPPORT_CPPTRACE_H_
9
+ #define XGRAMMAR_SUPPORT_CPPTRACE_H_
10
+
11
+ #include < cpptrace/cpptrace.hpp>
12
+
13
+ namespace xgrammar {
14
+
15
+ inline void PrintTrace () { cpptrace::generate_trace ().print (); }
16
+
17
+ } // namespace xgrammar
18
+
19
+ #endif // XGRAMMAR_SUPPORT_CPPTRACE_H_
You can’t perform that action at this time.
0 commit comments