aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2019-08-28 09:52:12 +0200
committerGerald Combs <gerald@wireshark.org>2019-08-28 16:51:01 +0000
commit92ac2f509915b73198d7f7beef6ede11983df524 (patch)
treecc9c4b5d0fd7b767bb99d10559761548495d8351 /cmake
parent8806701215502d5b7fffbb4be8690e80e1eb5876 (diff)
cmake: fix issue when zstd is missing.
We need to check the library version only when the it's present, otherwise we hit an error. Change-Id: I6323b19d0023d466bfb6ae4b5751f376fc213fa4 Reviewed-on: https://code.wireshark.org/review/34387 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/FindZSTD.cmake22
1 files changed, 12 insertions, 10 deletions
diff --git a/cmake/modules/FindZSTD.cmake b/cmake/modules/FindZSTD.cmake
index 54f9281869..3fefe0fa08 100644
--- a/cmake/modules/FindZSTD.cmake
+++ b/cmake/modules/FindZSTD.cmake
@@ -31,16 +31,18 @@ find_library(ZSTD_LIBRARY
/usr/local/lib
)
-file(STRINGS ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_MAJOR
- REGEX "#define[ ]+ZSTD_VERSION_MAJOR[ ]+[0-9]+")
-string(REGEX MATCH "[0-9]+" ZSTD_VERSION_MAJOR ${ZSTD_VERSION_MAJOR})
-file(STRINGS ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_MINOR
- REGEX "#define[ ]+ZSTD_VERSION_MINOR[ ]+[0-9]+")
-string(REGEX MATCH "[0-9]+" ZSTD_VERSION_MINOR ${ZSTD_VERSION_MINOR})
-file(STRINGS ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_RELEASE
- REGEX "#define[ ]+ZSTD_VERSION_RELEASE[ ]+[0-9]+")
-string(REGEX MATCH "[0-9]+" ZSTD_VERSION_RELEASE ${ZSTD_VERSION_RELEASE})
-set(ZSTD_VERSION ${ZSTD_VERSION_MAJOR}.${ZSTD_VERSION_MINOR}.${ZSTD_VERSION_RELEASE})
+if( ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY )
+ file(STRINGS ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_MAJOR
+ REGEX "#define[ ]+ZSTD_VERSION_MAJOR[ ]+[0-9]+")
+ string(REGEX MATCH "[0-9]+" ZSTD_VERSION_MAJOR ${ZSTD_VERSION_MAJOR})
+ file(STRINGS ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_MINOR
+ REGEX "#define[ ]+ZSTD_VERSION_MINOR[ ]+[0-9]+")
+ string(REGEX MATCH "[0-9]+" ZSTD_VERSION_MINOR ${ZSTD_VERSION_MINOR})
+ file(STRINGS ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_RELEASE
+ REGEX "#define[ ]+ZSTD_VERSION_RELEASE[ ]+[0-9]+")
+ string(REGEX MATCH "[0-9]+" ZSTD_VERSION_RELEASE ${ZSTD_VERSION_RELEASE})
+ set(ZSTD_VERSION ${ZSTD_VERSION_MAJOR}.${ZSTD_VERSION_MINOR}.${ZSTD_VERSION_RELEASE})
+endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZSTD