File: Findzstd.cmake

package info (click to toggle)
cpptrace 1.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,996 kB
  • sloc: cpp: 15,646; python: 962; ansic: 155; sh: 103; makefile: 86
file content (51 lines) | stat: -rw-r--r-- 1,581 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Libdwarf needs zstd, cpptrace doesn't, and libdwarf has its own Findzstd but it doesn't define zstd::libzstd_static /
# zstd::libzstd_shared targets which leads to issues, necessitating a find_dependency(zstd) in cpptrace's cmake config
# and in order to support non-cmake-module installs we need to provide a Findzstd script.
# https://github.com/jeremy-rifkin/cpptrace/issues/112

# This will define
# zstd_FOUND
# zstd_INCLUDE_DIR
# zstd_LIBRARY

find_path(zstd_INCLUDE_DIR NAMES zstd.h)

find_library(zstd_LIBRARY_DEBUG NAMES zstdd zstd_staticd)
find_library(zstd_LIBRARY_RELEASE NAMES zstd zstd_static)

include(SelectLibraryConfigurations)
SELECT_LIBRARY_CONFIGURATIONS(zstd)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
  zstd DEFAULT_MSG
  zstd_LIBRARY zstd_INCLUDE_DIR
)

if(zstd_FOUND)
  message(STATUS "Found Zstd: ${zstd_LIBRARY}")
endif()

mark_as_advanced(zstd_INCLUDE_DIR zstd_LIBRARY)

if(zstd_FOUND)
  # just defining them the same... cmake will figure it out
  if(NOT TARGET zstd::libzstd_static)
    add_library(zstd::libzstd_static UNKNOWN IMPORTED)
    set_target_properties(
      zstd::libzstd_static
      PROPERTIES
      IMPORTED_LOCATION "${zstd_LIBRARIES}"
      INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
    )
  endif()
  if(NOT TARGET zstd::libzstd_shared)
    add_library(zstd::libzstd_shared UNKNOWN IMPORTED)
    set_target_properties(
      zstd::libzstd_shared
      PROPERTIES
      IMPORTED_LOCATION "${zstd_LIBRARIES}"
      INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
    )
  endif()
endif()