[PATCH] D17196: [test-suite] Use cmake `find_package` to search zLib for ClamAV test case

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 04:55:05 PST 2016


atanasyan created this revision.
atanasyan added reviewers: rengolin, MatzeB.
atanasyan added a subscriber: llvm-commits.
atanasyan set the repository for this revision to rL LLVM.

- in case of cross-compilation using `find_package` allows to provide path to target specific libraries using single CMAKE_PREFIX_PATH variable.

- zLib is manadatory for ClamAV test case so if it does not exist it is better to get know about that early

- if zLib cannot be found as a standard package we still can use it providing paths to headers and libraries explicitly by CMAKE_xxx_FLAGS variables

Repository:
  rL LLVM

http://reviews.llvm.org/D17196

Files:
  MultiSource/Applications/ClamAV/CMakeLists.txt

Index: MultiSource/Applications/ClamAV/CMakeLists.txt
===================================================================
--- MultiSource/Applications/ClamAV/CMakeLists.txt
+++ MultiSource/Applications/ClamAV/CMakeLists.txt
@@ -12,7 +12,19 @@
 set(INPUT ${CMAKE_CURRENT_SOURCE_DIR}/inputs/clam.cab ${CMAKE_CURRENT_SOURCE_DIR}/inputs/clamdoc.tar.gz ${CMAKE_CURRENT_SOURCE_DIR}/inputs/clam.exe ${CMAKE_CURRENT_SOURCE_DIR}/inputs/clam.exe.bz2 ${CMAKE_CURRENT_SOURCE_DIR}/inputs/clam-v2.rar ${CMAKE_CURRENT_SOURCE_DIR}/inputs/clam-v3.rar ${CMAKE_CURRENT_SOURCE_DIR}/inputs/clam.zip ${CMAKE_CURRENT_SOURCE_DIR}/inputs/README ${CMAKE_CURRENT_SOURCE_DIR}/inputs/rtf-test/Doc11.rtf ${CMAKE_CURRENT_SOURCE_DIR}/inputs/rtf-test/Doc1.rtf ${CMAKE_CURRENT_SOURCE_DIR}/inputs/rtf-test/Doc22.rtf ${CMAKE_CURRENT_SOURCE_DIR}/inputs/rtf-test/Doc2.rtf ${CMAKE_CURRENT_SOURCE_DIR}/inputs/rtf-test/doc3.rtf ${CMAKE_CURRENT_SOURCE_DIR}/inputs/rtf-test/docCLAMexe.rtf ${CMAKE_CURRENT_SOURCE_DIR}/inputs/rtf-test/rtf1.rtf ${CMAKE_CURRENT_SOURCE_DIR}/inputs/rtf-test/rtf-novirus.rtf)
 set(PROG clamscan)
 list(APPEND CPPFLAGS -DHAVE_CONFIG_H -I. -DDONT_LOCK_DBDIRS)
-set(LDFLAGS -lz)
+
+# Find zLib library required for building ClamAV
+find_package(ZLIB)
+if (ZLIB_FOUND)
+  include_directories(${ZLIB_INCLUDE_DIRS})
+  set(LDFLAGS ${ZLIB_LIBRARIES})
+else (ZLIB_FOUND)
+  # If we do not find the package, we can still use the zlib
+  # providing paths to to look up headers and libraries using
+  # xxx_FLAGS variables.
+  set(LDFLAGS -lz)
+endif (ZLIB_FOUND)
+
 set(RUN_OPTIONS --debug --exclude-dir .svn --verbose -d${CMAKE_CURRENT_SOURCE_DIR}/dbdir -r ${INPUT})
 if("${TARGET_OS}" STREQUAL "Darwin")
   list(APPEND CPPFLAGS -DC_DARWIN)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17196.47793.patch
Type: text/x-patch
Size: 1717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160212/49b486c5/attachment.bin>


More information about the llvm-commits mailing list