mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Fix cmake -DEVENT__COVERAGE=ON
- do not use compiler check from the root cmake rules with syntax error, let CodeCoverage check it - fix CodeCoverage to check C compiler not CXX - case insensitive checking of CMAKE_BUILD_TYPE - replace flags with --coverage, and fix flags with linking with --coverate, otherwise it will not compile during checking flags and fails.
This commit is contained in:
parent
9585338f6c
commit
40fbffc0df
@ -28,6 +28,7 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release
|
||||
CACHE STRING "Set build type to Debug o Release (default Release)" FORCE)
|
||||
endif()
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
|
||||
|
||||
# get rid of the extra default configurations
|
||||
# what? why would you get id of other useful build types? - Ellzey
|
||||
@ -152,16 +153,15 @@ endif()
|
||||
|
||||
# Setup compiler flags for coverage.
|
||||
if (EVENT__COVERAGE)
|
||||
if ((NOT CMAKE_COMPILER_IS_GNUCC) AND (NOT ${CMAKE_CXX_COMPILER_ID} STREQAL "Clang"))
|
||||
message(FATAL_ERROR "Trying to compile coverage support, but compiler is not GNU gcc! Try CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake <options> ..")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
if (NOT "${CMAKE_BUILD_TYPE_LOWER}" STREQUAL "debug")
|
||||
message(FATAL_ERROR "Coverage requires -DCMAKE_BUILD_TYPE=Debug")
|
||||
endif()
|
||||
|
||||
message(STATUS "Setting coverage compiler flags")
|
||||
add_compiler_flags(-g -O0 -fprofile-arcs -ftest-coverage)
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES "--coverage")
|
||||
add_compiler_flags(-g -O0 --coverage)
|
||||
set(CMAKE_REQUIRED_LIBRARIES "")
|
||||
endif()
|
||||
|
||||
# GCC specific options.
|
||||
|
@ -30,6 +30,9 @@
|
||||
# - Added support for Clang.
|
||||
# - Some additional usage instructions.
|
||||
#
|
||||
# 2016-11-02, Azat Khuzhin
|
||||
# - Adopt for C compiler only (libevent)
|
||||
#
|
||||
# USAGE:
|
||||
# 1. Copy this file into your cmake modules path.
|
||||
#
|
||||
@ -68,11 +71,11 @@ IF(NOT GCOV_PATH)
|
||||
MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
|
||||
ENDIF() # NOT GCOV_PATH
|
||||
|
||||
IF(NOT CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||
IF(NOT CMAKE_COMPILER_IS_GNUCC)
|
||||
# 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")
|
||||
IF(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
||||
MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
|
||||
ENDIF()
|
||||
ENDIF() # NOT CMAKE_COMPILER_IS_GNUCC
|
||||
|
Loading…
x
Reference in New Issue
Block a user