Skip to content

Commit bb2c97a

Browse files
committed
2 parents 421ed9c + 2f650bd commit bb2c97a

File tree

3 files changed

+26
-47
lines changed

3 files changed

+26
-47
lines changed

CMakeLists.txt

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
1818

1919
# ======================================== PROJECT SETUP ========================================
2020
set(BUILD_SHARED_LIBS OFF) # Don't build shared libs
21-
project(Connection_Machine VERSION 0.9.0)
21+
project(Connection_Machine VERSION 0.8.0)
2222
if (APPLE)
2323
set(APP_NAME "Connection Machine") # name of the bundle
2424
else()
@@ -41,28 +41,13 @@ option(CONNECTION_MACHINE_BUILD_TESTS "Build Connection Machine Tests" OFF)
4141
option(CONNECTION_MACHINE_CODE_COVERAGE "Enable code coverage reporting" OFF)
4242
option(RUN_TRACY_PROFILER "Enable runtime profiler" OFF)
4343

44+
# ====================================== SILENCE WARNINGS =======================================
45+
4446
if(MSVC)
4547
# C4244: 'conversion' conversion from 'type1' to 'type2', possible loss of data
4648
# C4267: 'var' conversion from 'size_t' to 'type', possible loss of data
47-
add_compile_options(/wd4244 /wd4267)
48-
endif()
49-
50-
# ======================================= COVERAGE SETUP ========================================
51-
52-
if(CONNECTION_MACHINE_CODE_COVERAGE)
53-
if (CONNECTION_MACHINE_BUILD_TESTS)
54-
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
55-
message(STATUS "Code coverage enabled")
56-
add_compile_options(--coverage -O0 -g)
57-
add_link_options(--coverage)
58-
elseif(MSVC)
59-
message(WARNING "Code coverage not supported with MSVC. Use Clang-cl or OpenCppCoverage.")
60-
else()
61-
message(WARNING "Code coverage not working with: \"${CMAKE_CXX_COMPILER_ID}\"")
62-
endif()
63-
else()
64-
message(WARNING "Code coverage cant not be used without also enabling tests.")
65-
endif()
49+
# C4018: 'var' signed/unsigned mismatch
50+
add_compile_options(/wd4244 /wd4267 /wd4018)
6651
endif()
6752

6853
set(EXTERNAL_LINKS)

cmake/makeTests.cmake

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CPMAddPackage(
77
GITHUB_REPOSITORY google/googletest
88
GIT_TAG v1.17.0
99
SOURCE_DIR "${EXTERNAL_DIR}/gtest"
10+
OPTIONS "gtest_force_shared_crt ON"
1011
)
1112

1213
set(TEST_DIR "${CMAKE_SOURCE_DIR}/tests")
@@ -32,29 +33,20 @@ add_executable(${PROJECT_NAME}_tests ${TEST_FILES})
3233
target_include_directories(${PROJECT_NAME}_tests PRIVATE ${SOURCE_DIR} ${TEST_DIR} "${EXTERNAL_DIR}/wasmtime")
3334
target_link_libraries(${PROJECT_NAME}_tests PRIVATE ${EXTERNAL_LINKS})
3435

35-
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
36-
target_compile_options(${PROJECT_NAME}_tests PRIVATE --coverage -O0 -g)
37-
target_link_options(${PROJECT_NAME}_tests PRIVATE --coverage)
38-
endif()
39-
4036
target_precompile_headers(${PROJECT_NAME}_tests PRIVATE "${SOURCE_DIR}/precompiled.h")
4137

42-
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
43-
find_program(GCOVR_PATH gcovr)
44-
if(NOT GCOVR_PATH)
45-
message(FATAL_ERROR "gcovr not found! Please install it via pip: pip install gcovr")
38+
if(CONNECTION_MACHINE_CODE_COVERAGE)
39+
if (CONNECTION_MACHINE_BUILD_TESTS)
40+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
41+
message(STATUS "Code coverage enabled")
42+
add_compile_options(--coverage -O0 -g)
43+
add_link_options(--coverage)
44+
elseif(MSVC)
45+
message(WARNING "Code coverage does nothing with MSVC. Use normal Tests build, and use opencpp_coverage.cmd")
46+
else()
47+
message(WARNING "Code coverage not working with: \"${CMAKE_CXX_COMPILER_ID}\"")
48+
endif()
49+
else()
50+
message(WARNING "Code coverage cant not be used without also enabling tests.")
4651
endif()
47-
48-
add_custom_target(coverage
49-
COMMAND ${GCOVR_PATH}
50-
--root ${CMAKE_SOURCE_DIR}
51-
--filter ${SOURCE_DIR}
52-
--exclude-unreachable-branches
53-
--print-summary
54-
--html --html-details -o coverage.html
55-
--gcov-executable gcov
56-
--exclude '${EXTERNAL_DIR}'
57-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
58-
COMMENT "Generating code coverage report with gcovr"
59-
)
60-
endif()
52+
endif()

opencpp_coverage.cmd

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
set PROJ_SRC=%CD%\src
1+
set PROJ=%CD%
2+
set TESTEXE=%PROJ%\build-tests\Debug\Connection_Machine_tests.exe
3+
24
mkdir coverage
5+
36
OpenCppCoverage ^
4-
--sources "%PROJ_SRC%\*" ^
7+
--sources %PROJ%\src ^
58
--cover_children ^
69
--export_type cobertura:coverage\coverage.xml ^
710
--export_type html:coverage ^
8-
-- build-tests\Debug\Connection_Machine_tests.exe ^
9-
--gtest_output=xml:coverage\gtest.xml
11+
-- "%TESTEXE%" --gtest_output=xml:coverage\gtest.xml

0 commit comments

Comments
 (0)