Skip to content

Commit

Permalink
chore(cmake): Fixes to properly build/link Trace on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
matejk committed Sep 16, 2024
1 parent 877673a commit f8106cb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ else()
endif(UNIX AND NOT ANDROID)
endif(CYGWIN)

if(ENABLE_TRACE)
target_link_libraries(Foundation PUBLIC Poco::Trace)
endif()

if(CMAKE_SYSTEM MATCHES "SunOS")
target_compile_definitions(Foundation
PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion Foundation/samples/trace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_executable(sample-trace src/trace.cpp)
target_link_libraries(sample-trace PUBLIC Poco::Trace)
target_link_libraries(sample-trace PUBLIC Poco::Foundation)
13 changes: 8 additions & 5 deletions Trace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,29 @@ set_target_properties(Trace
DEFINE_SYMBOL Trace_EXPORTS
)

target_include_directories (Trace PRIVATE include/Poco/Trace)
target_compile_definitions (Trace PRIVATE cpptrace_lib_EXPORTS)

target_compile_definitions (Trace PRIVATE CPPTRACE_STATIC_DEFINE)

if (LINUX)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_compile_definitions (Trace PRIVATE CPPTRACE_DEMANGLE_WITH_CXXABI CPPTRACE_UNWIND_WITH_UNWIND)
target_compile_definitions (Trace PRIVATE CPPTRACE_GET_SYMBOLS_WITH_LIBBACKTRACE)
target_link_libraries(Trace PRIVATE backtrace)
elseif (APPLE)
target_compile_definitions (Trace PRIVATE CPPTRACE_DEMANGLE_WITH_CXXABI CPPTRACE_UNWIND_WITH_UNWIND)
target_compile_definitions (Trace PRIVATE CPPTRACE_GET_SYMBOLS_WITH_LIBDL)
elseif(WIN32)
target_compile_definitions (Trace PRIVATE CPPTRACE_DEMANGLE_WITH_WINAPI CPPTRACE_UNWIND_WITH_WINAPI)
target_compile_definitions (Trace PRIVATE CPPTRACE_GET_SYMBOLS_WITH_DBGHELP NOMINMAX)
target_link_libraries(Trace PRIVATE dbghelp)
else()
message(FATAL_ERROR "Poco::Trace: Unsupported platform.")
endif()

target_link_libraries(Trace PUBLIC Poco::Foundation)
target_compile_definitions (Trace PUBLIC POCO_ENABLE_TRACE)

target_include_directories(Trace
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/Poco/Trace>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
)
Expand Down

0 comments on commit f8106cb

Please sign in to comment.