Skip to content

Commit

Permalink
Merge 36cd5ec into 8cc621c
Browse files Browse the repository at this point in the history
  • Loading branch information
thetic committed Oct 29, 2022
2 parents 8cc621c + 36cd5ec commit 311be02
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 143 deletions.
62 changes: 18 additions & 44 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,83 +58,57 @@ jobs:
# Windows
- os: windows-latest
cpp_version: 17
preset: MSVC
- os: windows-latest
cpp_version: 17
preset: ClangCL
# Linux
# CMake different C++ versions with clang
- os: ubuntu-latest
cpp_version: 98
cxx: clang++
cc: clang
preset: Clang
- os: ubuntu-latest
cpp_version: 11
cxx: clang++
cc: clang
preset: Clang
- os: ubuntu-latest
cpp_version: 14
cxx: clang++
cc: clang
preset: Clang
- os: ubuntu-latest
cpp_version: 17
cxx: clang++
cc: clang
preset: Clang
# CMake different C++ versions with gcc
- os: ubuntu-latest
cpp_version: 98
cxx: g++
cc: gcc
preset: GNU
- os: ubuntu-latest
cpp_version: 11
cxx: g++
cc: gcc
preset: GNU
- os: ubuntu-latest
cpp_version: 14
cxx: g++
cc: gcc
preset: GNU
- os: ubuntu-latest
cpp_version: 17
cxx: g++
cc: gcc
preset: GNU
# Mac OSX
- os: macos-latest
cpp_version: 98
preset: defaults
- os: macos-latest
cpp_version: 17
cxx: clang++
cc: clang
preset: Clang
- os: macos-latest
cpp_version: 14
cxx: g++
cc: gcc
preset: GNU
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@main
- if: ${{ matrix.cxx }}
run: echo "CXX=${{ matrix.cxx }}" >> $GITHUB_ENV
- if: ${{ matrix.cc }}
run: echo "CC=${{ matrix.cc }}" >> $GITHUB_ENV
- name: Configure
run: >
cmake
-B build
-S .
--preset ${{ matrix.preset }}
-D CMAKE_CXX_STANDARD=${{ matrix.cpp_version }}
- name: Build
run: cmake --build build --verbose
- name: Test
run: ctest --test-dir build

visualstudio-clangcl:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Configure
run: >
cmake
-B build
-G "Visual Studio 17 2022"
-T ClangCL
- name: Build
run: cmake --build build --verbose
run: cmake --build cpputest_build --verbose
- name: Test
run: ctest --test-dir build
run: ctest --test-dir cpputest_build
38 changes: 8 additions & 30 deletions .github/workflows/extended.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ jobs:
- name: Checkout
uses: actions/checkout@main
- name: Configure
run: >
cmake
-S .
-B cpputest_build
-D CMAKE_BUILD_TYPE=Debug
-D CMAKE_CXX_STANDARD=11
-D CPPUTEST_COVERAGE=ON
-D CPPUTEST_EXAMPLES=OFF
run: cmake --preset coverage
- name: Build
run: cmake --build cpputest_build
- name: Test
Expand Down Expand Up @@ -79,38 +72,27 @@ jobs:

cmake_wine:
runs-on: ubuntu-latest
env:
CC: x86_64-w64-mingw32-gcc
CXX: x86_64-w64-mingw32-g++
steps:
- name: Install tools
run: sudo apt-get install -y mingw-w64 wine64
- name: Checkout
uses: actions/checkout@main
- name: Configure
run: >
cmake
-B build
-S .
-D CMAKE_SYSTEM_NAME=Windows
-D CMAKE_CROSSCOMPILING_EMULATOR=wine
cmake --preset MinGW
- name: Build
run: cmake --build build --verbose
run: cmake --build cpputest_build --verbose
- name: Test
run: ctest --test-dir build
run: ctest --test-dir cpputest_build

cmake_no_exceptions:
cmake_no_std_cpp:
runs-on: ubuntu-latest
name: Disable exceptions
env:
CC: gcc
CXX: g++
CXXFLAGS: -fno-exceptions
steps:
- name: Checkout
uses: actions/checkout@main
- name: Configure
run: cmake -B cpputest_build -S .
run: cmake --preset no-std-cpp
- name: Build
run: cmake --build cpputest_build --verbose
- name: Test
Expand All @@ -123,7 +105,7 @@ jobs:
uses: actions/checkout@main
- name: Install
run: |
cmake -B cpputest_build/ -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --preset GNU
cmake --build cpputest_build/ -j
ctest --test-dir cpputest_build/
sudo cmake --install cpputest_build/
Expand All @@ -146,11 +128,7 @@ jobs:
sudo dpkg --install qemu.deb
rm -f qemu.deb
- name: Configure
run: >
cmake
-B cpputest_build
-D CMAKE_TOOLCHAIN_FILE=cmake/arm-none-eabi-gcc.toolchain.cmake
-D CMAKE_CROSSCOMPILING_EMULATOR="qemu-arm-static;-cpu;cortex-m4"
run: cmake --preset arm-embedded
- name: Build
run: cmake --build cpputest_build
- name: Test
Expand Down
23 changes: 0 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ check_type_size("long long" SIZEOF_LONGLONG)
cmake_dependent_option(CPPUTEST_USE_LONG_LONG "Support long long"
YES "HAVE_SIZEOF_LONGLONG" OFF)

cmake_dependent_option(CPPUTEST_MAP_FILE "Enable the creation of a map file"
OFF "CPPUTEST_FLAGS;NOT MSVC" OFF)
cmake_dependent_option(CPPUTEST_COVERAGE "Enable running with coverage"
OFF "CPPUTEST_FLAGS;NOT MSVC" OFF)
cmake_dependent_option(CPPUTEST_WERROR
"Compile with warnings as errors"
ON "CPPUTEST_FLAGS;PROJECT_IS_TOP_LEVEL" OFF
)
cmake_dependent_option(CPPUTEST_BUILD_TESTING "Compile and make tests for CppUTest"
${PROJECT_IS_TOP_LEVEL} "BUILD_TESTING" OFF)
option(CPPUTEST_TESTS_DETAILED "Run each test separately instead of grouped?" OFF)
Expand Down Expand Up @@ -115,18 +107,6 @@ check_cxx_symbol_exists(fopen_s "stdio.h" CPPUTEST_HAVE_SECURE_STDLIB)
cmake_dependent_option(CPPUTEST_USE_SECURE_STDLIB "Use MSVC safe functions"
ON "WIN32;CPPUTEST_HAVE_SECURE_STDLIB" OFF)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # Don't change users' build type.
# Multi-configuration generators don't have a single build type.
get_property(
GENERATOR_IS_MULTI_CONFIG GLOBAL
PROPERTY GENERATOR_IS_MULTI_CONFIG
)
if(NOT GENERATOR_IS_MULTICONFIG AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "What kind of build this is" FORCE)
message("No CMAKE_BUILD_TYPE set. Assigning: ${CMAKE_BUILD_TYPE}")
endif()
endif()

set( CppUTestLibName "CppUTest" )
set( CppUTestExtLibName "CppUTestExt" )

Expand Down Expand Up @@ -300,9 +280,6 @@ Features configured in CppUTest:
Disable Standard C library: ${CPPUTEST_STD_C_LIB_DISABLED}
Disable Standard C++ library: ${CPPUTEST_STD_CPP_LIB_DISABLED}
Generating map file: ${CPPUTEST_MAP_FILE}
Compiling with coverage: ${CPPUTEST_COVERAGE}
Compile and run self-tests ${CPPUTEST_BUILD_TESTING}
Run self-tests separately ${CPPUTEST_TESTS_DETAILED}
Expand Down
85 changes: 85 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"version": 3,
"configurePresets": [
{
"name": "defaults",
"binaryDir": "cpputest_build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_EXTENSIONS": false
}
},
{
"name": "GNU",
"inherits": ["defaults"],
"environment": {
"CFLAGS": "-Werror",
"CXXFLAGS": "-Werror"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "Clang",
"inherits": ["GNU"],
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
}
},
{
"name": "MSVC",
"inherits": ["defaults"],
"environment": {
"CFLAGS": "/WX",
"CXXFLAGS": "/WX"
}
},
{
"name": "ClangCL",
"inherits": ["MSVC"],
"generator": "Visual Studio 17 2022",
"toolset": "ClangCL"
},
{
"name": "MinGW",
"inherits": ["GNU"],
"cacheVariables": {
"CMAKE_C_COMPILER": "x86_64-w64-mingw32-gcc",
"CMAKE_CXX_COMPILER": "x86_64-w64-mingw32-g++",
"CMAKE_SYSTEM_NAME": "Windows",
"CMAKE_CROSSCOMPILING_EMULATOR": "wine"
}
},
{
"name": "arm-embedded",
"inherits": ["defaults"],
"toolchainFile": "${sourceDir}/cmake/arm-none-eabi-gcc.toolchain.cmake",
"cacheVariables": {
"CMAKE_CROSSCOMPILING_EMULATOR": "qemu-arm-static;-cpu;cortex-m4"
}
},
{
"name": "coverage",
"inherits": ["GNU"],
"environment": {
"CFLAGS": "--coverage",
"CXXFLAGS": "--coverage"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_STANDARD": "11",
"CPPUTEST_EXAMPLES": false
}
},
{
"name": "no-std-cpp",
"inherits": ["GNU"],
"environment": {
"CXXFLAGS": "-Werror -fno-exceptions -fno-rtti -nostdinc++"
}
}
]
}
35 changes: 0 additions & 35 deletions cmake/Modules/CppUTestConfigurationOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ if (CPPUTEST_PLATFORM STREQUAL "IAR")
unset(CMAKE_CXX_EXTENSION_COMPILE_OPTION)
# Set up the CMake variables for the linker
set(LINKER_SCRIPT "${CppUTest_SOURCE_DIR}/platforms/iar/CppUTestTest.icf")
set(CMAKE_C_LINK_FLAGS "--semihosting --config ${LINKER_SCRIPT} --map mapfile.map")
set(CMAKE_CXX_LINK_FLAGS "--semihosting --config ${LINKER_SCRIPT} --map mapfile.map")
elseif (CPPUTEST_PLATFORM STREQUAL "BORLAND")
set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -w-8008 -w-8066")
elseif (CPPUTEST_PLATFORM STREQUAL "GccNoStdC")
Expand All @@ -15,12 +13,6 @@ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CppUTestWarningFlags)
endif ()

if (CPPUTEST_STD_CPP_LIB_DISABLED)
if (NOT CPPUTEST_STD_C_LIB_DISABLED AND NOT MSVC)
set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -nostdinc++")
endif ()
endif ()

if (NOT CPPUTEST_MEM_LEAK_DETECTION_DISABLED)
if (MSVC)
set(CPPUTEST_C_FLAGS "${CPPUTEST_C_FLAGS} /FI \"${CppUTest_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorMallocMacros.h\"")
Expand All @@ -36,33 +28,6 @@ if (NOT CPPUTEST_MEM_LEAK_DETECTION_DISABLED)
endif (MSVC)
endif ()

if (CPPUTEST_MAP_FILE AND NOT MSVC)
set(CPPUTEST_LD_FLAGS "${CPPUTEST_LD_FLAGS} -Wl,-Map,$<.map.txt")
endif ()

if (CPPUTEST_COVERAGE AND NOT MSVC)
set(CPPUTEST_C_FLAGS "${CPPUTEST_C_FLAGS} --coverage")
set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} --coverage")
set(CMAKE_BUILD_TYPE "Debug")
find_program(GCOVR gcovr DOC "gcovr executable")

if (NOT GCOVR)
message(SEND_ERROR "gcovr not found")
endif()

add_custom_target(coverage ${GCOVR}
--root ${PROJECT_SOURCE_DIR}
--output "${CMAKE_BINARY_DIR}/coverage/coverage.html"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generate coverage data"
VERBATIM
)
endif()

if (CMAKE_CXX_STANDARD)
set(CMAKE_CXX_EXTENSIONS OFF)
endif ()

set(GMOCK_HOME $ENV{GMOCK_HOME})
if (DEFINED ENV{GMOCK_HOME})
# GMock pulls in gtest.
Expand Down

0 comments on commit 311be02

Please sign in to comment.