diff --git a/CMakeLists.txt b/CMakeLists.txt index 520c241f..8cf39093 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,13 +59,11 @@ include(CheckStructHasMember) include(CheckCSourceCompiles) include(CheckPrototypeDefinition) -include(FindZLIB) # -> HAVE_LIBZ - # Setup compiler flags for coverage. if (EVENT__COVERAGE) - if(NOT CMAKE_COMPILER_IS_GNUCXX) + if(NOT CMAKE_COMPILER_IS_GNUCC) if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - message(FATAL_ERROR "Compiler is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ..") + message(FATAL_ERROR "Trying to compile coverage support (--DEVENT__COVERAGE) but compiler is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ..") endif() endif() @@ -581,11 +579,16 @@ if (NOT EVENT__DISABLE_THREAD_SUPPORT) endif() endif() -if (ZLIB_LIBRARY) - set(EVENT__HAVE_ZLIB 1) - set(EVENT__HAVE_ZLIB_H) - include_directories(${ZLIB_INCLUDE_DIRS}) - list(APPEND LIB_APPS ${ZLIB_LIBRARIES}) +if (NOT EVENT__DISABLE_TESTS) + # Zlib is only used for testing. + find_package(ZLIB) + + if (ZLIB_LIBRARY) + set(EVENT__HAVE_ZLIB 1) + set(EVENT__HAVE_ZLIB_H) + include_directories(${ZLIB_INCLUDE_DIRS}) + list(APPEND LIB_APPS ${ZLIB_LIBRARIES}) + endif() endif() set(SRC_EXTRA diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 2afefa1d..969f2732 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -68,14 +68,14 @@ IF(NOT GCOV_PATH) MESSAGE(FATAL_ERROR "gcov not found! Aborting...") ENDIF() # NOT GCOV_PATH -IF(NOT CMAKE_COMPILER_IS_GNUCXX) +IF(NOT CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_COMPILER_IS_GNUCXX) # Clang version 3.0.0 and greater now supports gcov as well. MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.") IF(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") ENDIF() -ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX +ENDIF() # NOT CMAKE_COMPILER_IS_GNUCC IF ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" )