Skip to content

Commit

Permalink
ci: 💫 update CI config
Browse files Browse the repository at this point in the history
  • Loading branch information
rodneylab committed Apr 20, 2024
1 parent 9cd9d8f commit b2038e6
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 67 deletions.
74 changes: 7 additions & 67 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,74 +27,14 @@ target_compile_options(
include(cmake/StaticAnalysers.cmake)
enable_clang_tidy()

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")
option(RUN_TESTS "Enable tests" ON)
include(coverage)
add_coverage_target("Catch_tests/*")

# The configurations we support
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution")

# if(MSVC) # 64 bit architecture set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE
# "x64")
#
# # Set runtime library if(USE_STATIC_MSVC_RUNTIME_LIBRARY)
# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") else()
# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
# endif()
#
# # Set general compiler flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
# /Zc:__cplusplus /Gm- /Wall /WX /MP /nologo /diagnostics:classic /FC
# /fp:except- /Zc:inline" )
#
# # Optionally generate debug symbols if(GENERATE_DEBUG_SYMBOLS)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi") endif()
#
# # Remove any existing compiler flag that enables RTTI string(REPLACE "/GR" ""
# CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
#
# # Set compiler flag for disabling RTTI set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
# /GR-")
#
# if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM") # On ARM the exception handling
# flag is missing which causes warnings set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
# /EHsc") endif()
#
# # Set compiler flags for various configurations set(CMAKE_CXX_FLAGS_DEBUG "/GS
# /Od /Ob0 /RTC1") set(CMAKE_CXX_FLAGS_RELEASE "/GS- /Gy /O2 /Oi /Ot")
# set(CMAKE_CXX_FLAGS_DISTRIBUTION "/GS- /Gy /O2 /Oi /Ot")
#
# # Set linker flags if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# if(CROSS_PLATFORM_DETERMINISTIC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
# /fp:precise") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast") #
# Clang doesn't use # fast math because it # cannot be turned off # inside a
# single # compilation unit endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL
# "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /showFilenames")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") # Clang emits #
# warnings # about unused # arguments # such as /MP # and /GL endif() else() #
# Set general compiler flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall
# -Werror")
#
# # Optionally generate debug symbols if(GENERATE_DEBUG_SYMBOLS)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") endif()
#
# if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # Also disable
# -Wstringop-overflow or it will generate false positives that # can't be
# disabled from code when link-time optimizations are enabled Also # turn off
# automatic fused multiply add contractions, there doesn't seem to # be a way to
# do this selectively through the macro JPH_PRECISE_MATH_OFF set(CMAKE_CXX_FLAGS
# "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow -ffp-contract=off") else() # Do not
# use -ffast-math since it cannot be turned off in a single # compilation unit
# under clang, see Core.h set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
# -ffp-model=precise")
#
# # On clang 14 and later we can turn off float contraction through a pragma, #
# older versions and deterministic versions need it off always, see Core.h
# if(CMAKE_CXX_COMPILER_VERSION LESS 14 OR CROSS_PLATFORM_DETERMINISTIC)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-contract=off") endif() endif()
#
# # Set compiler flags for various configurations set(CMAKE_CXX_FLAGS_DEBUG "")
# set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O3")
#
# # Set linker flags if(NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows"))
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread") endif()
# endif()

# Set linker flags
set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")

Expand Down Expand Up @@ -127,6 +67,6 @@ set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "JoltRaylibHelloWorld")

option(RUN_UNIT_TESTS "Run Catch2 unit tests" ON)
if(RUN_UNIT_TESTS)
enable_testing()
add_subdirectory(Catch_tests)
enable_testing()
add_subdirectory(Catch_tests)
endif()
63 changes: 63 additions & 0 deletions cmake/coverage.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Source: https://github.com/cmake-modules/lcov
#
# MIT License
#
# Copyright (c) 2020 cmake-modules
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

function(add_coverage_target exclude)

find_program(GCOV gcov)
if (NOT GCOV)
message(WARNING "program gcov not found")
endif()

find_program(LCOV lcov)
if (NOT LCOV)
message(WARNING "program lcov not found")
endif()

find_program(GENHTML genhtml)
if (NOT GENHTML)
message(WARNING "program genhtml not found")
endif()

if (LCOV AND GCOV AND GENHTML)
#set(covname cov.info)
set(covname lcov.txt)
add_compile_options(-fprofile-arcs -ftest-coverage)
add_link_options(--coverage)
add_custom_target(cov DEPENDS ${covname})
add_custom_command(
OUTPUT ${covname}
COMMAND ${LCOV} -c -o ${covname} -d . -b . --gcov-tool ${GCOV}
COMMAND ${LCOV} -r ${covname} -o ${covname} ${exclude} --exclude "*/SFML/System" --exclude "*/catch2/*" --exclude "v1/*"
COMMAND ${LCOV} -l ${covname}
COMMAND ${GENHTML} ${covname} -output coverage
COMMAND ${LCOV} -l ${covname} 2>/dev/null | grep Total | sed 's/|//g' | sed 's/Total://g' | awk '{print $1}' | sed s/%//g > coverage/total
)
set_directory_properties(PROPERTIES
ADDITIONAL_CLEAN_FILES ${covname}
)
else()
message(WARNING "unable to add target `cov`: missing coverage tools")
endif()

endfunction()

0 comments on commit b2038e6

Please sign in to comment.