Enable cmake formatting (#53)
* enable cmake formatting * update style check workflow * update readme * update wording
This commit is contained in:
parent
4e87a9410a
commit
866ae707e5
8 changed files with 142 additions and 85 deletions
56
.cmake-format
Normal file
56
.cmake-format
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
format:
|
||||||
|
tab_size: 2
|
||||||
|
line_width: 100
|
||||||
|
dangle_parens: true
|
||||||
|
|
||||||
|
parse:
|
||||||
|
additional_commands:
|
||||||
|
cpmaddpackage:
|
||||||
|
pargs:
|
||||||
|
nargs: '*'
|
||||||
|
flags: []
|
||||||
|
spelling: CPMAddPackage
|
||||||
|
kwargs: &cpmaddpackagekwargs
|
||||||
|
NAME: 1
|
||||||
|
FORCE: 1
|
||||||
|
VERSION: 1
|
||||||
|
GIT_TAG: 1
|
||||||
|
DOWNLOAD_ONLY: 1
|
||||||
|
GITHUB_REPOSITORY: 1
|
||||||
|
GITLAB_REPOSITORY: 1
|
||||||
|
GIT_REPOSITORY: 1
|
||||||
|
SVN_REPOSITORY: 1
|
||||||
|
SVN_REVISION: 1
|
||||||
|
SOURCE_DIR: 1
|
||||||
|
DOWNLOAD_COMMAND: 1
|
||||||
|
FIND_PACKAGE_ARGUMENTS: 1
|
||||||
|
NO_CACHE: 1
|
||||||
|
GIT_SHALLOW: 1
|
||||||
|
URL: 1
|
||||||
|
URL_HASH: 1
|
||||||
|
URL_MD5: 1
|
||||||
|
DOWNLOAD_NAME: 1
|
||||||
|
DOWNLOAD_NO_EXTRACT: 1
|
||||||
|
HTTP_USERNAME: 1
|
||||||
|
HTTP_PASSWORD: 1
|
||||||
|
OPTIONS: +
|
||||||
|
cpmfindpackage:
|
||||||
|
pargs:
|
||||||
|
nargs: '*'
|
||||||
|
flags: []
|
||||||
|
spelling: CPMFindPackage
|
||||||
|
kwargs: *cpmaddpackagekwargs
|
||||||
|
packageproject:
|
||||||
|
pargs:
|
||||||
|
nargs: '*'
|
||||||
|
flags: []
|
||||||
|
spelling: packageProject
|
||||||
|
kwargs:
|
||||||
|
NAME: 1
|
||||||
|
VERSION: 1
|
||||||
|
INCLUDE_DIR: 1
|
||||||
|
INCLUDE_DESTINATION: 1
|
||||||
|
BINARY_DIR: 1
|
||||||
|
COMPATIBILITY: 1
|
||||||
|
VERSION_HEADER: 1
|
||||||
|
DEPENDENCIES: +
|
6
.github/workflows/style.yml
vendored
6
.github/workflows/style.yml
vendored
|
@ -16,8 +16,10 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
- name: Install clang-format
|
- name: Install format dependencies
|
||||||
run: brew install clang-format
|
run: |
|
||||||
|
brew install clang-format
|
||||||
|
pip install cmake_format pyyaml
|
||||||
|
|
||||||
- name: configure
|
- name: configure
|
||||||
run: cmake -Htest -Bbuild
|
run: cmake -Htest -Bbuild
|
||||||
|
|
|
@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||||
# ---- Project ----
|
# ---- Project ----
|
||||||
|
|
||||||
# Note: update this to your new project's name and version
|
# Note: update this to your new project's name and version
|
||||||
project(Greeter
|
project(
|
||||||
|
Greeter
|
||||||
VERSION 1.0
|
VERSION 1.0
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
@ -11,7 +12,10 @@ project(Greeter
|
||||||
# ---- Include guards ----
|
# ---- Include guards ----
|
||||||
|
|
||||||
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
|
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
|
||||||
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.")
|
message(
|
||||||
|
FATAL_ERROR
|
||||||
|
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---- Add dependencies via CPM ----
|
# ---- Add dependencies via CPM ----
|
||||||
|
@ -28,16 +32,16 @@ CPMAddPackage(
|
||||||
|
|
||||||
# ---- Add source files ----
|
# ---- Add source files ----
|
||||||
|
|
||||||
# Note: globbing sources is considered bad practice as CMake's generators may not detect new files automatically.
|
# Note: globbing sources is considered bad practice as CMake's generators may not detect new files
|
||||||
# Keep that in mind when changing files, or explicitly mention them here.
|
# automatically. Keep that in mind when changing files, or explicitly mention them here.
|
||||||
FILE(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
|
file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
|
||||||
FILE(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")
|
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")
|
||||||
|
|
||||||
# ---- Create library ----
|
# ---- Create library ----
|
||||||
|
|
||||||
# Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface target:
|
# Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface
|
||||||
# add_library(Greeter INTERFACE)
|
# target: add_library(Greeter INTERFACE) set_target_properties(Greeter PROPERTIES
|
||||||
# set_target_properties(Greeter PROPERTIES INTERFACE_COMPILE_FEATURES cxx_std_17)
|
# INTERFACE_COMPILE_FEATURES cxx_std_17)
|
||||||
|
|
||||||
add_library(Greeter ${headers} ${sources})
|
add_library(Greeter ${headers} ${sources})
|
||||||
|
|
||||||
|
@ -46,20 +50,18 @@ set_target_properties(Greeter PROPERTIES CXX_STANDARD 17)
|
||||||
# being a cross-platform target, we enforce standards conformance on MSVC
|
# being a cross-platform target, we enforce standards conformance on MSVC
|
||||||
target_compile_options(Greeter PUBLIC "$<$<BOOL:${MSVC}>:/permissive->")
|
target_compile_options(Greeter PUBLIC "$<$<BOOL:${MSVC}>:/permissive->")
|
||||||
|
|
||||||
# Link dependencies (if required)
|
# Link dependencies (if required) target_link_libraries(Greeter PUBLIC cxxopts)
|
||||||
# target_link_libraries(Greeter PUBLIC cxxopts)
|
|
||||||
|
|
||||||
target_include_directories(Greeter
|
target_include_directories(
|
||||||
PUBLIC
|
Greeter PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
|
||||||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---- Create an installable target ----
|
# ---- Create an installable target ----
|
||||||
# this allows users to install and find the library via `find_package()`.
|
# this allows users to install and find the library via `find_package()`.
|
||||||
|
|
||||||
# the location where the project's version header will be placed
|
# the location where the project's version header will be placed should match the project's regular
|
||||||
# should match the project's regular header paths
|
# header paths
|
||||||
string(TOLOWER ${PROJECT_NAME}/version.h VERSION_HEADER_LOCATION)
|
string(TOLOWER ${PROJECT_NAME}/version.h VERSION_HEADER_LOCATION)
|
||||||
|
|
||||||
packageProject(
|
packageProject(
|
||||||
|
|
|
@ -22,7 +22,7 @@ This template is the result of learnings from many previous projects and should
|
||||||
- Integrated test suite
|
- Integrated test suite
|
||||||
- Continuous integration via [GitHub Actions](https://help.github.com/en/actions/)
|
- Continuous integration via [GitHub Actions](https://help.github.com/en/actions/)
|
||||||
- Code coverage via [codecov](https://codecov.io)
|
- Code coverage via [codecov](https://codecov.io)
|
||||||
- Code formatting enforced by [clang-format](https://clang.llvm.org/docs/ClangFormat.html) via [Format.cmake](https://github.com/TheLartians/Format.cmake)
|
- Code formatting enforced by [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and [cmake-format](https://github.com/cheshirekow/cmake_format) via [Format.cmake](https://github.com/TheLartians/Format.cmake)
|
||||||
- Reproducible dependency management via [CPM.cmake](https://github.com/TheLartians/CPM.cmake)
|
- Reproducible dependency management via [CPM.cmake](https://github.com/TheLartians/CPM.cmake)
|
||||||
- Installable target with automatic versioning information and header generation via [PackageProject.cmake](https://github.com/TheLartians/PackageProject.cmake)
|
- Installable target with automatic versioning information and header generation via [PackageProject.cmake](https://github.com/TheLartians/PackageProject.cmake)
|
||||||
- Automatic [documentation](https://thelartians.github.io/ModernCppStarter) and deployment with [Doxygen](https://www.doxygen.nl) and [GitHub Pages](https://pages.github.com)
|
- Automatic [documentation](https://thelartians.github.io/ModernCppStarter) and deployment with [Doxygen](https://www.doxygen.nl) and [GitHub Pages](https://pages.github.com)
|
||||||
|
@ -68,7 +68,8 @@ To collect code coverage information, run CMake with the `-DENABLE_TEST_COVERAGE
|
||||||
|
|
||||||
### Run clang-format
|
### Run clang-format
|
||||||
|
|
||||||
Use the following commands from the project's root directory to run clang-format (must be installed on the host system).
|
Use the following commands from the project's root directory to check and fix C++ and CMake source style.
|
||||||
|
This requires _clang-format_, _cmake-format_ and _pyyaml_ to be installed on the current system.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cmake -Htest -Bbuild/test
|
cmake -Htest -Bbuild/test
|
||||||
|
@ -80,7 +81,7 @@ cmake --build build/test --target format
|
||||||
cmake --build build/test --target fix-format
|
cmake --build build/test --target fix-format
|
||||||
```
|
```
|
||||||
|
|
||||||
See [Format.cmake](https://github.com/TheLartians/Format.cmake) for more options.
|
See [Format.cmake](https://github.com/TheLartians/Format.cmake) for details.
|
||||||
|
|
||||||
### Build the documentation
|
### Build the documentation
|
||||||
|
|
||||||
|
|
|
@ -1,41 +1,59 @@
|
||||||
# this file contains a list of tools that can be activated and downloaded on-demand
|
# this file contains a list of tools that can be activated and downloaded on-demand each tool is
|
||||||
# each tool is enabled during configuration by passing an additional `-DUSE_<TOOL>=<VALUE>` argument to CMake
|
# enabled during configuration by passing an additional `-DUSE_<TOOL>=<VALUE>` argument to CMake
|
||||||
|
|
||||||
# only activate tools for top level project
|
# only activate tools for top level project
|
||||||
if (NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
||||||
|
|
||||||
# enables sanitizers support using the the `USE_SANITIZER` flag
|
# enables sanitizers support using the the `USE_SANITIZER` flag available values are: Address,
|
||||||
# available values are: Address, Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined'
|
# Memory, MemoryWithOrigins, Undefined, Thread, Leak, 'Address;Undefined'
|
||||||
if (USE_SANITIZER OR USE_STATIC_ANALYZER)
|
if(USE_SANITIZER OR USE_STATIC_ANALYZER)
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME StableCoder-cmake-scripts
|
NAME StableCoder-cmake-scripts
|
||||||
GITHUB_REPOSITORY StableCoder/cmake-scripts
|
GITHUB_REPOSITORY StableCoder/cmake-scripts
|
||||||
GIT_TAG 3d2d5a9fb26f0ce24e3e4eaeeff686ec2ecfb3fb
|
GIT_TAG 3d2d5a9fb26f0ce24e3e4eaeeff686ec2ecfb3fb
|
||||||
)
|
)
|
||||||
|
|
||||||
if (USE_SANITIZER)
|
if(USE_SANITIZER)
|
||||||
include(${StableCoder-cmake-scripts_SOURCE_DIR}/sanitizers.cmake)
|
include(${StableCoder-cmake-scripts_SOURCE_DIR}/sanitizers.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_STATIC_ANALYZER)
|
if(USE_STATIC_ANALYZER)
|
||||||
if ("clang-tidy" IN_LIST USE_STATIC_ANALYZER)
|
if("clang-tidy" IN_LIST USE_STATIC_ANALYZER)
|
||||||
SET(CLANG_TIDY ON CACHE INTERNAL "")
|
set(CLANG_TIDY
|
||||||
|
ON
|
||||||
|
CACHE INTERNAL ""
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
SET(CLANG_TIDY OFF CACHE INTERNAL "")
|
set(CLANG_TIDY
|
||||||
|
OFF
|
||||||
|
CACHE INTERNAL ""
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
if ("iwyu" IN_LIST USE_STATIC_ANALYZER)
|
if("iwyu" IN_LIST USE_STATIC_ANALYZER)
|
||||||
SET(IWYU ON CACHE INTERNAL "")
|
set(IWYU
|
||||||
|
ON
|
||||||
|
CACHE INTERNAL ""
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
SET(IWYU OFF CACHE INTERNAL "")
|
set(IWYU
|
||||||
|
OFF
|
||||||
|
CACHE INTERNAL ""
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
if ("cppcheck" IN_LIST USE_STATIC_ANALYZER)
|
if("cppcheck" IN_LIST USE_STATIC_ANALYZER)
|
||||||
SET(CPPCHECK ON CACHE INTERNAL "")
|
set(CPPCHECK
|
||||||
|
ON
|
||||||
|
CACHE INTERNAL ""
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
SET(CPPCHECK OFF CACHE INTERNAL "")
|
set(CPPCHECK
|
||||||
|
OFF
|
||||||
|
CACHE INTERNAL ""
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(${StableCoder-cmake-scripts_SOURCE_DIR}/tools.cmake)
|
include(${StableCoder-cmake-scripts_SOURCE_DIR}/tools.cmake)
|
||||||
|
@ -46,9 +64,8 @@ if (USE_SANITIZER OR USE_STATIC_ANALYZER)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# enables CCACHE support through the USE_CCACHE flag
|
# enables CCACHE support through the USE_CCACHE flag possible values are: YES, NO or equivalent
|
||||||
# possible values are: YES, NO or equivalent
|
if(USE_CCACHE)
|
||||||
if (USE_CCACHE)
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME Ccache.cmake
|
NAME Ccache.cmake
|
||||||
GITHUB_REPOSITORY TheLartians/Ccache.cmake
|
GITHUB_REPOSITORY TheLartians/Ccache.cmake
|
||||||
|
|
|
@ -6,10 +6,7 @@ project(GreeterDocs)
|
||||||
|
|
||||||
include(../cmake/CPM.cmake)
|
include(../cmake/CPM.cmake)
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||||
NAME Greeter
|
|
||||||
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..
|
|
||||||
)
|
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME MCSS
|
NAME MCSS
|
||||||
|
@ -27,15 +24,9 @@ set(DOXYGEN_PROJECT_VERSION ${Greeter_VERSION})
|
||||||
set(DOXYGEN_PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/..")
|
set(DOXYGEN_PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/..")
|
||||||
set(DOXYGEN_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doxygen")
|
set(DOXYGEN_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doxygen")
|
||||||
|
|
||||||
configure_file(
|
configure_file(${CMAKE_CURRENT_LIST_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||||
${CMAKE_CURRENT_LIST_DIR}/Doxyfile
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_file(
|
configure_file(${CMAKE_CURRENT_LIST_DIR}/conf.py ${CMAKE_CURRENT_BINARY_DIR}/conf.py)
|
||||||
${CMAKE_CURRENT_LIST_DIR}/conf.py
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/conf.py
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
GenerateDocs
|
GenerateDocs
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||||
|
|
||||||
project(GreeterStandalone
|
project(GreeterStandalone LANGUAGES CXX)
|
||||||
LANGUAGES CXX
|
|
||||||
)
|
|
||||||
|
|
||||||
# --- Import tools ----
|
# --- Import tools ----
|
||||||
|
|
||||||
|
@ -16,15 +14,10 @@ CPMAddPackage(
|
||||||
NAME cxxopts
|
NAME cxxopts
|
||||||
GITHUB_REPOSITORY jarro2783/cxxopts
|
GITHUB_REPOSITORY jarro2783/cxxopts
|
||||||
VERSION 2.2.0
|
VERSION 2.2.0
|
||||||
OPTIONS
|
OPTIONS "CXXOPTS_BUILD_EXAMPLES Off" "CXXOPTS_BUILD_TESTS Off"
|
||||||
"CXXOPTS_BUILD_EXAMPLES Off"
|
|
||||||
"CXXOPTS_BUILD_TESTS Off"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||||
NAME Greeter
|
|
||||||
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..
|
|
||||||
)
|
|
||||||
|
|
||||||
# ---- Create standalone executable ----
|
# ---- Create standalone executable ----
|
||||||
|
|
||||||
|
@ -32,9 +25,6 @@ file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
|
||||||
|
|
||||||
add_executable(GreeterStandalone ${sources})
|
add_executable(GreeterStandalone ${sources})
|
||||||
|
|
||||||
set_target_properties(GreeterStandalone PROPERTIES
|
set_target_properties(GreeterStandalone PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Greeter")
|
||||||
CXX_STANDARD 17
|
|
||||||
OUTPUT_NAME "Greeter"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(GreeterStandalone Greeter cxxopts)
|
target_link_libraries(GreeterStandalone Greeter cxxopts)
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||||
|
|
||||||
project(GreeterTests
|
project(GreeterTests LANGUAGES CXX)
|
||||||
LANGUAGES CXX
|
|
||||||
)
|
|
||||||
|
|
||||||
# ---- Options ----
|
# ---- Options ----
|
||||||
|
|
||||||
|
@ -23,19 +21,20 @@ CPMAddPackage(
|
||||||
GIT_TAG 2.3.7
|
GIT_TAG 2.3.7
|
||||||
)
|
)
|
||||||
|
|
||||||
if (TEST_INSTALLED_VERSION)
|
if(TEST_INSTALLED_VERSION)
|
||||||
find_package(Greeter REQUIRED)
|
find_package(Greeter REQUIRED)
|
||||||
else()
|
else()
|
||||||
CPMAddPackage(
|
CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||||
NAME Greeter
|
|
||||||
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME Format.cmake
|
NAME Format.cmake
|
||||||
GITHUB_REPOSITORY TheLartians/Format.cmake
|
GITHUB_REPOSITORY TheLartians/Format.cmake
|
||||||
VERSION 1.5.2
|
VERSION 1.6
|
||||||
|
OPTIONS # enable cmake formatting
|
||||||
|
"FORMAT_CHECK_CMAKE ON"
|
||||||
|
# skip CPM.cmake
|
||||||
|
"CMAKE_FORMAT_EXCLUDE cmake/CPM.cmake"
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---- Create binary ----
|
# ---- Create binary ----
|
||||||
|
@ -47,8 +46,8 @@ target_link_libraries(GreeterTests doctest Greeter)
|
||||||
set_target_properties(GreeterTests PROPERTIES CXX_STANDARD 17)
|
set_target_properties(GreeterTests PROPERTIES CXX_STANDARD 17)
|
||||||
|
|
||||||
# enable compiler warnings
|
# enable compiler warnings
|
||||||
if (NOT TEST_INSTALLED_VERSION)
|
if(NOT TEST_INSTALLED_VERSION)
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
target_compile_options(Greeter PUBLIC -Wall -pedantic -Wextra -Werror)
|
target_compile_options(Greeter PUBLIC -Wall -pedantic -Wextra -Werror)
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
target_compile_options(Greeter PUBLIC /W4 /WX)
|
target_compile_options(Greeter PUBLIC /W4 /WX)
|
||||||
|
@ -58,18 +57,17 @@ endif()
|
||||||
|
|
||||||
# ---- Add GreeterTests ----
|
# ---- Add GreeterTests ----
|
||||||
|
|
||||||
ENABLE_TESTING()
|
enable_testing()
|
||||||
|
|
||||||
# Note: doctest and similar testing frameworks can automatically configure CMake tests
|
# Note: doctest and similar testing frameworks can automatically configure CMake tests For other
|
||||||
# For other testing frameworks add the tests target instead:
|
# testing frameworks add the tests target instead: ADD_TEST(GreeterTests GreeterTests)
|
||||||
# ADD_TEST(GreeterTests GreeterTests)
|
|
||||||
|
|
||||||
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
|
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
|
||||||
doctest_discover_tests(GreeterTests)
|
doctest_discover_tests(GreeterTests)
|
||||||
|
|
||||||
# ---- code coverage ----
|
# ---- code coverage ----
|
||||||
|
|
||||||
if (ENABLE_TEST_COVERAGE)
|
if(ENABLE_TEST_COVERAGE)
|
||||||
target_compile_options(Greeter PUBLIC -O0 -g -fprofile-arcs -ftest-coverage)
|
target_compile_options(Greeter PUBLIC -O0 -g -fprofile-arcs -ftest-coverage)
|
||||||
target_link_options(Greeter PUBLIC -fprofile-arcs -ftest-coverage)
|
target_link_options(Greeter PUBLIC -fprofile-arcs -ftest-coverage)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue