Skip to content

Commit

Permalink
Merge pull request #15 from karel-burda/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
karel-burda authored Sep 27, 2018
2 parents 907d2de + 568717b commit d2e1f43
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Version](https://img.shields.io/badge/version-0.8.1-green.svg)
![Version](https://img.shields.io/badge/version-0.9.0-green.svg)
[![License](https://img.shields.io/badge/license-MIT_License-green.svg?style=flat)](LICENSE)
[![Build Status](https://travis-ci.org/karel-burda/cmake-helpers.svg?branch=master)](https://travis-ci.org/karel-burda/cmake-helpers)

Expand Down
3 changes: 2 additions & 1 deletion cmake-helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

project(cmake-helpers VERSION 0.8.1 LANGUAGES NONE)
project(cmake-helpers VERSION 0.9.0 LANGUAGES NONE)

set(OTHER
../README.md
../.travis.yml)

set(SRCS
code-coverage.cmake
get-windows-version.cmake
gtest.cmake
messages.cmake
Expand Down
23 changes: 23 additions & 0 deletions cmake-helpers/code-coverage.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
macro(_coverage_add_build_options _TARGET)
target_compile_options(
${_TARGET}
PRIVATE $<$<CXX_COMPILER_ID:GNU>:
-fprofile-arcs
-ftest-coverage>)

target_compile_options(
${_TARGET}
PRIVATE $<$<CXX_COMPILER_ID:Clang>:
-fprofile-arcs
-ftest-coverage
-fcoverage-mapping
-fprofile-instr-generate>)

# Cannot use expression generator in set_target_properties()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set_target_properties(
${_TARGET}
PROPERTIES
LINK_FLAGS "-fprofile-arcs -ftest-coverage")
endif()
endmacro()
6 changes: 2 additions & 4 deletions cmake-helpers/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ macro(_gtest_resolve_build_options _TARGET)
_gtest_include_headers(${_TARGET})
_gtest_link(${_TARGET})
_gtest_add_compile_options(${_TARGET})

_link_threads_if_available(${_TARGET})
endmacro()

Expand All @@ -46,8 +47,5 @@ macro(_gtest_link _TARGET)
endmacro()

macro(_gtest_add_compile_options _TARGET)
if (MSVC)
target_compile_options(${_TARGET} PUBLIC /MT)
endif()

target_compile_options(${_TARGET} PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/MT>)
endmacro()
8 changes: 6 additions & 2 deletions cmake-helpers/messages.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
macro(_print_status_message _MESSAGE)
message(STATUS "${PROJECT_NAME}: ${_MESSAGE}")
if (PROJECT_NAME)
message(STATUS "${PROJECT_NAME}: ${_MESSAGE}")
endif()
endmacro()

macro(_print_project_version)
_print_status_message("${PROJECT_NAME} is in version: ${PROJECT_VERSION}")
if (PROJECT_VERSION)
_print_status_message("${PROJECT_NAME} is in version: ${PROJECT_VERSION}")
endif()
endmacro()
4 changes: 3 additions & 1 deletion tests/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

project(integration-tests VERSION 0.8.1 LANGUAGES NONE)
project(integration-tests VERSION 0.9.0 LANGUAGES NONE)

set(SRCS
get-windows-version.test.cmake
Expand All @@ -10,6 +10,7 @@ set(SRCS
if(${RUN_INTEGRATION_TESTS})
include("run-all-integration-tests.cmake")

include(${CMAKE_SOURCE_DIR}/cmake-helpers/code-coverage.cmake)
include(${CMAKE_SOURCE_DIR}/cmake-helpers/messages.cmake)
include(${CMAKE_SOURCE_DIR}/cmake-helpers/threads.cmake)

Expand All @@ -21,6 +22,7 @@ if(${RUN_INTEGRATION_TESTS})
add_dependencies(${PROJECT_NAME} gtest-build)

_gtest_resolve_build_options(${PROJECT_NAME})
_coverage_add_build_options(${PROJECT_NAME})
else()
add_custom_target(${PROJECT_NAME} ${SRCS})
endif()
2 changes: 1 addition & 1 deletion tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

project(unit-tests VERSION 0.8.1 LANGUAGES NONE)
project(unit-tests VERSION 0.9.0 LANGUAGES NONE)

set(SRCS
messages.test.cmake
Expand Down

0 comments on commit d2e1f43

Please sign in to comment.