aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-07 13:54:49 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-07 13:56:59 -0700
commit124114c0a8add705d4c3affb6f602b0a36eb4237 (patch)
treef820133b5e4a38579a026ed4f5ebe00ccf7b0493 /CMakeLists.txt
parentb02a4341a9214cc57587c300171824d79b346913 (diff)
downloadnng-124114c0a8add705d4c3affb6f602b0a36eb4237.tar.gz
nng-124114c0a8add705d4c3affb6f602b0a36eb4237.tar.bz2
nng-124114c0a8add705d4c3affb6f602b0a36eb4237.zip
Richer CI support on Travis, including code coverage.
We use codecov.io; this seems to work well.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt22
1 files changed, 21 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c6d25f1b..eb93bda2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,8 @@
# Copyright (c) 2012 Martin Sustrik All rights reserved.
# Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
# Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved.
-# Copyright 2016 Garrett D'Amore <garrett@damore.org>
# Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
+# Copyright 2017 Garrett D'Amore <garrett@damore.org>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"),
@@ -33,6 +33,7 @@ include (CheckStructHasMember)
include (CheckLibraryExists)
include (CheckCSourceCompiles)
include (GNUInstallDirs)
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if (POLICY CMP0042)
# Newer cmake on MacOS should use @rpath
@@ -90,12 +91,31 @@ option (NNG_ENABLE_DOC "Enable building documentation." ON)
option (NNG_TESTS "Build and run tests" ON)
option (NNG_TOOLS "Build extra tools" OFF)
option (NNG_ENABLE_NNGCAT "Enable building nngcat utility." ${NNG_TOOLS})
+option (NNG_ENABLE_COVERAGE "Enable coverage reporting." OFF)
# Enable access to private APIs for our own use.
add_definitions (-DNNG_PRIVATE)
# Platform checks.
+if (NNG_ENABLE_COVERAGE)
+ # NB: This only works for GCC and Clang 3.0 and newer. If your stuff
+ # is older than that, you will need to find something newer. For
+ # correct reporting, we always turn off all optimizations.
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ set(CMAKE_C_FLAGS -g -O0 -fprofile-arcs -ftest-coverage)
+ set(CMAKE_CXX_FLAGS -g -O0 -fprofile-arcs -ftest-coverage)
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set(CMAKE_C_FLAGS -g -O0 -fprofile-arcs -ftest-coverage)
+ set(CMAKE_CXX_FLAGS -g -O0 -fprofile-arcs -ftest-coverage)
+ elseif (CMAKE_COMPILER_ID STREQUAL "AppleClang")
+ set(CMAKE_C_FLAGS -g -O0 -fprofile-arcs -ftest-coverage)
+ set(CMAKE_CXX_FLAGS -g -O0 -fprofile-arcs -ftest-coverage)
+ else()
+ message(FATAL_ERROR "Unable to enable coverage for your compiler.")
+ endif()
+endif()
+
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package (Threads REQUIRED)
add_definitions (-DPLATFORM_POSIX)