aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/EthCompilerSettings.cmake
diff options
context:
space:
mode:
authorPaweł Bylica <chfast@gmail.com>2018-07-04 21:12:08 +0800
committerPaweł Bylica <chfast@gmail.com>2018-07-24 23:12:41 +0800
commit807f7533d9e56eea0c137d2147293d9a6bab279a (patch)
tree29a736ac70eceedd233901990ab1f7402718cbc0 /cmake/EthCompilerSettings.cmake
parent721b7bbf70cd7e54c5dc49bf61851eaa1ab12e9a (diff)
downloaddexon-solidity-807f7533d9e56eea0c137d2147293d9a6bab279a.tar.gz
dexon-solidity-807f7533d9e56eea0c137d2147293d9a6bab279a.tar.zst
dexon-solidity-807f7533d9e56eea0c137d2147293d9a6bab279a.zip
CMake: Add option COVERAGE
This also removed PROFILE option that also adds --coverage flag. Instead you can use -DCMAKE_EXE_LINKER_FLAGS=-lprofiler. The profiling options can be added back when better investigated (e.g. -lprofiler vs -pg options).
Diffstat (limited to 'cmake/EthCompilerSettings.cmake')
-rw-r--r--cmake/EthCompilerSettings.cmake32
1 files changed, 17 insertions, 15 deletions
diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake
index ff3a5edb..ee8cb1b3 100644
--- a/cmake/EthCompilerSettings.cmake
+++ b/cmake/EthCompilerSettings.cmake
@@ -151,21 +151,23 @@ if (SANITIZE)
endif()
endif()
-if (PROFILING AND (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")))
- set(CMAKE_CXX_FLAGS "-g ${CMAKE_CXX_FLAGS}")
- set(CMAKE_C_FLAGS "-g ${CMAKE_C_FLAGS}")
- add_definitions(-DETH_PROFILING_GPERF)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lprofiler")
-# set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -lprofiler")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lprofiler")
-endif ()
-
-if (PROFILING AND (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")))
- set(CMAKE_CXX_FLAGS "-g --coverage ${CMAKE_CXX_FLAGS}")
- set(CMAKE_C_FLAGS "-g --coverage ${CMAKE_C_FLAGS}")
- set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS} -lprofiler")
- set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS} -lprofiler")
-endif ()
+# Code coverage support.
+# Copied from Cable:
+# https://github.com/ethereum/cable/blob/v0.2.4/CableCompilerSettings.cmake#L118-L132
+option(COVERAGE "Build with code coverage support" OFF)
+if(COVERAGE)
+ # Set the linker flags first, they are required to properly test the compiler flag.
+ set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
+
+ set(CMAKE_REQUIRED_LIBRARIES "--coverage ${CMAKE_REQUIRED_LIBRARIES}")
+ check_cxx_compiler_flag(--coverage have_coverage)
+ string(REPLACE "--coverage " "" CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ if(NOT have_coverage)
+ message(FATAL_ERROR "Coverage not supported")
+ endif()
+ add_compile_options(-g --coverage)
+endif()
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
option(USE_LD_GOLD "Use GNU gold linker" ON)