Skip to content

Commit

Permalink
cmake: Look for Dwarfutils (OSX)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKagstrom committed Aug 16, 2023
1 parent 614ed34 commit a4a299a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8.4)
cmake_minimum_required (VERSION 2.8.12)
project (kcov)

set (PROJECT_VERSION_MAJOR 39)
Expand Down
35 changes: 35 additions & 0 deletions cmake/FindDwarfutils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# - Try to find dwarfutils

if (DWARFUTILS_LIBRARIES AND DWARFUTILS_INCLUDE_DIRS)
set (DWARFUTILS_FIND_QUIETLY ON)
endif (DWARFUTILS_LIBRARIES AND DWARFUTILS_INCLUDE_DIRS)

find_path (DWARFUTILS_INCLUDE_DIR
NAMES
libdwarf.h
PATHS
/usr/local/opt/dwarfutils/include/libdwarf-0/
/opt/homebrew/opt/dwarfutils/include/libdwarf-0/
ENV CPATH)

find_library (DWARFUTILS_LIBRARY
NAMES
dwarf
PATHS
/usr/local/opt/dwarfutils/lib/
/opt/homebrew/opt/dwarfutils/lib/
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)

include (FindPackageHandleStandardArgs)


# handle the QUIETLY and REQUIRED arguments and set DWARFUTILS_FOUND to TRUE if all listed variables are TRUE
find_package_handle_standard_args(dwarfutils DEFAULT_MSG
DWARFUTILS_LIBRARY
DWARFUTILS_INCLUDE_DIR)

mark_as_advanced(DWARFUTILS_INCLUDE_DIR DWARFUTILS_LIBRARY)

set(DWARFUTILS_LIBRARIES ${DWARFUTILS_LIBRARY} )
set(DWARFUTILS_INCLUDE_DIRS ${DWARFUTILS_INCLUDE_DIR} )
9 changes: 6 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
add_library (${SOLIB} SHARED ${${SOLIB}_SRCS})
set_target_properties(${SOLIB} PROPERTIES SUFFIX ".so")
else() # Mac OSX
find_package (dwarfutils REQUIRED)
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
Expand Down Expand Up @@ -298,8 +299,6 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -g -Wall -D_GLIBCXX_USE_NANO
include_directories(
include/
${ZLIB_INCLUDE_DIR}
# FIXME! Dont commit
/usr/local/opt/dwarfutils/include/libdwarf-0/
)

if (LIBDW_FOUND)
Expand All @@ -314,6 +313,10 @@ if (CURL_FOUND)
include_directories(${CURL_INCLUDE_DIRS})
endif (CURL_FOUND)

if (DWARFUTILS_FOUND)
include_directories(${DWARFUTILS_INCLUDE_DIRS})
endif ()

add_library (bash_execve_redirector SHARED engines/bash-execve-redirector.c)
set_target_properties(bash_execve_redirector PROPERTIES SUFFIX ".so")
target_link_libraries(bash_execve_redirector ${DL_LIBRARY})
Expand Down Expand Up @@ -454,7 +457,7 @@ if (LIBELF_FOUND)
${DISASSEMBLER_LIBRARIES}
${LIBDW_LIBRARIES}
${LIBELF_LIBRARIES}
/usr/local/opt/dwarfutils/lib/libdwarf.a
${DWARFUTILS_LIBRARIES}
"${M_LIBRARY}"
${ZLIB_LIBRARIES}
)
Expand Down

0 comments on commit a4a299a

Please sign in to comment.