comparison cmake/FindZSTD.cmake @ 313:dbfe05b88627

cmake: bring back for good It's just too complicated to get portability done right using pure GNU make and since we're targeting more OSes than Linux we have to incorporate some portability bits.
author David Demelier <markand@malikania.fr>
date Wed, 22 Sep 2021 07:19:32 +0200
parents
children 764f65dfa46d
comparison
equal deleted inserted replaced
312:4ea0f035f712 313:dbfe05b88627
1 # FindZSTD
2 # --------
3 #
4 # Find ZSTD library, this modules defines:
5 #
6 # ZSTD_INCLUDE_DIRS, where to find zstd.h
7 # ZSTD_LIBRARIES, where to find library
8 # ZSTD_FOUND, if it is found
9 # ZSTD_EXE, path to zstd executable if found
10 #
11 # The following imported targets will be available:
12 #
13 # ZSTD::ZSTD, if found.
14 # ZSTD::exe, alias to ZSTD_EXE
15 #
16
17 find_path(ZSTD_INCLUDE_DIR NAMES zstd.h)
18 find_library(ZSTD_LIBRARY NAMES libzstd zstd)
19 find_program(ZSTD_EXE NAMES zstd)
20
21 include(FindPackageHandleStandardArgs)
22
23 find_package_handle_standard_args(
24 ZSTD
25 FOUND_VAR ZSTD_FOUND
26 REQUIRED_VARS ZSTD_LIBRARY ZSTD_INCLUDE_DIR
27 )
28
29 if (ZSTD_FOUND)
30 set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
31 set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
32
33 if (NOT TARGET ZSTD::ZSTD)
34 add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
35 set_target_properties(
36 ZSTD::ZSTD
37 PROPERTIES
38 IMPORTED_LINK_INTERFACE_LANGUAGES "C"
39 IMPORTED_LOCATION "${ZSTD_LIBRARY}"
40 INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}"
41 )
42 endif ()
43
44 if (NOT TARGET ZSTD::exe)
45 add_executable(ZSTD::exe IMPORTED GLOBAL)
46 set_target_properties(ZSTD::exe PROPERTIES IMPORTED_LOCATION "${ZSTD_EXE}")
47 endif ()
48 endif ()
49
50 mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY)