Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
# Try to find the zstd library
2
#
3
# If successful, the following variables will be defined:
4
# zstd_INCLUDE_DIR
5
# zstd_LIBRARY
6
# zstd_STATIC_LIBRARY
7
# zstd_FOUND
8
#
9
# Additionally, one of the following import targets will be defined:
10
# zstd::libzstd_shared
11
# zstd::libzstd_static
12
 
13
if(MSVC)
14
  set(zstd_STATIC_LIBRARY_SUFFIX "_static\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
15
else()
16
  set(zstd_STATIC_LIBRARY_SUFFIX "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
17
endif()
18
 
19
find_path(zstd_INCLUDE_DIR NAMES zstd.h)
20
find_library(zstd_LIBRARY NAMES zstd zstd_static)
21
find_library(zstd_STATIC_LIBRARY NAMES
22
  zstd_static
23
  "${CMAKE_STATIC_LIBRARY_PREFIX}zstd${CMAKE_STATIC_LIBRARY_SUFFIX}")
24
 
25
include(FindPackageHandleStandardArgs)
26
find_package_handle_standard_args(
27
    zstd DEFAULT_MSG
28
    zstd_LIBRARY zstd_INCLUDE_DIR
29
)
30
 
31
if(zstd_FOUND)
32
  if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$")
33
    set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
34
  elseif (NOT TARGET zstd::libzstd_shared)
35
    add_library(zstd::libzstd_shared SHARED IMPORTED)
36
    if(MSVC)
37
      # IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
38
      get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY)
39
      string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}")
40
      get_filename_component(zstd_BASENAME "${zstd_LIBRARY}" NAME)
41
      string(REGEX REPLACE "\\${CMAKE_LINK_LIBRARY_SUFFIX}$" "${CMAKE_SHARED_LIBRARY_SUFFIX}" zstd_BASENAME "${zstd_BASENAME}")
42
      set_target_properties(zstd::libzstd_shared PROPERTIES
43
          INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
44
          IMPORTED_LOCATION "${zstd_DIRNAME}/${zstd_BASENAME}"
45
          IMPORTED_IMPLIB "${zstd_LIBRARY}")
46
      unset(zstd_DIRNAME)
47
      unset(zstd_BASENAME)
48
    else()
49
      set_target_properties(zstd::libzstd_shared PROPERTIES
50
          INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
51
          IMPORTED_LOCATION "${zstd_LIBRARY}")
52
    endif()
53
  endif()
54
  if(zstd_STATIC_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND
55
     NOT TARGET zstd::libzstd_static)
56
    add_library(zstd::libzstd_static STATIC IMPORTED)
57
    set_target_properties(zstd::libzstd_static PROPERTIES
58
        INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}"
59
        IMPORTED_LOCATION "${zstd_STATIC_LIBRARY}")
60
  endif()
61
endif()
62
 
63
unset(zstd_STATIC_LIBRARY_SUFFIX)
64
 
65
mark_as_advanced(zstd_INCLUDE_DIR zstd_LIBRARY zstd_STATIC_LIBRARY)