Fix Cmake file and no-op tracer creation
The cmake changes include:
- Set compiler to C++11
- Support for code coverage
- Strict compiler options
The no-op tracer incorrectly created enabled const tracer. This is fixed,
now it creates a disabled tracer.
Change-Id: Ia79ac082ee0cc32e395452c32796b593eda0b691
Signed-off-by: Roni Riska <roni.riska@nokia.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a3b0e0d..6a8d101 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,10 +30,19 @@
project(tracelibcpp LANGUAGES CXX C)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cxx1.cmake)
+add_compile_options(-Wall -Wextra -Werror)
+set(CMAKE_CXX_STANDARD 11)
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release)
+endif()
+
+set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
+set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set (tracelibcpp_VERSION_MAJOR "0")
set (tracelibcpp_VERSION_MINOR "0")
-set (tracelibcpp_VERSION_MICRO "2")
+set (tracelibcpp_VERSION_MICRO "3")
set (tracelibcpp_VERSION_STRING
"${tracelibcpp_VERSION_MAJOR}.${tracelibcpp_VERSION_MINOR}.${tracelibcpp_VERSION_MICRO}")
@@ -79,6 +88,8 @@
src/tracelib.cpp
)
+# Library versions are on by default
+# i.e. so versions
option(WITH_VERSION "Support for library versioning" ON)
if (WITH_VERSION)
@@ -86,10 +97,6 @@
SOVERSION ${tracelibcpp_VERSION_MAJOR})
endif (WITH_VERSION)
-# Library versions are on by default
-# i.e. so versions
-option(WITH_VERSION "Support for library versioning" ON)
-
if (WITH_VERSION)
set_target_properties(tracelibcpp PROPERTIES VERSION ${tracelibcpp_VERSION_STRING}
SOVERSION ${tracelibcpp_VERSION_MAJOR})
@@ -120,6 +127,12 @@
# Add google test
if (WITH_TESTING)
+ file(
+ DOWNLOAD https://raw.githubusercontent.com/bilke/cmake-modules/72d804cfbcf82a1e171200c9c02748fa4b7ea033/CodeCoverage.cmake
+ ${CMAKE_BINARY_DIR}/CodeCoverage.cmake)
+
+ include("${CMAKE_BINARY_DIR}/CodeCoverage.cmake")
+ APPEND_COVERAGE_COMPILER_FLAGS()
hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)
add_executable(testrunner