Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit 687c3d2

Browse files
authored
Merge pull request #196 from cpp-best-practices/enable_examples
Enable examples
2 parents a85fe3d + 719f728 commit 687c3d2

33 files changed

Lines changed: 703 additions & 894 deletions

.github/workflows/ci.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ jobs:
2929
matrix:
3030
os:
3131
- ubuntu-20.04
32-
- macos-10.15
33-
- windows-2019
32+
- macos-11
3433
compiler:
3534
# you can specify the version after `-` like "llvm-13.0.0".
3635
- llvm
@@ -46,25 +45,12 @@ jobs:
4645

4746
exclude:
4847
# mingw is determined by this author to be too buggy to support
49-
- os: windows-2019
48+
- os: macos-11
5049
compiler: gcc
51-
52-
include:
53-
# Add appropriate variables for gcov version required. This will intentionally break
54-
# if you try to use a compiler that does not have gcov set
55-
- compiler: gcc
56-
gcov_executable: gcov
57-
- compiler: llvm
58-
gcov_executable: "llvm-cov gcov"
59-
60-
# This exists solely to make sure a non-multiconfig build works
6150
- os: ubuntu-20.04
62-
compiler: gcc
63-
generator: "Unix Makefiles"
64-
build_type: Debug
65-
gcov_executable: gcov
66-
developer_mode: On
51+
compiler: llvm
6752

53+
include:
6854
- os: windows-2022
6955
compiler: msvc
7056
generator: "Visual Studio 17 2022"
@@ -79,12 +65,12 @@ jobs:
7965
compiler: msvc
8066
generator: "Visual Studio 17 2022"
8167
build_type: Debug
82-
developer_mode: Off
68+
developer_mode: OFF
8369
- os: windows-2022
8470
compiler: msvc
8571
generator: "Visual Studio 17 2022"
8672
build_type: Release
87-
developer_mode: Off
73+
developer_mode: OFF
8874

8975

9076

@@ -127,11 +113,16 @@ jobs:
127113
gcovr: true
128114
opencppcoverage: true
129115

116+
- name: Install Linux Packages Needed By SDL
117+
if: runner.os == 'Linux'
118+
run: |
119+
sudo apt-get -y install libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev libxcb-util-dev libegl-dev
120+
130121
# make sure coverage is only enabled for Debug builds, since it sets -O0 to make sure coverage
131122
# has meaningful results
132123
- name: Configure CMake
133124
run: |
134-
cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DENABLE_DEVELOPER_MODE:BOOL=${{matrix.developer_mode}} -DOPT_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }}
125+
cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DENABLE_DEVELOPER_MODE:BOOL=${{matrix.developer_mode}} -DOPT_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' && matrix.developer_mode == 'OFF' }}
135126
136127
- name: Build
137128
# Execute the build. You can specify a specific target with "--target <NAME>"

CMakeLists.txt

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
# uncomment to set a default CXX standard for the external tools like clang-tidy and cppcheck
4-
# and the targets that do not specify a standard.
5-
# If not set, the latest supported standard for your compiler is used
6-
# You can later set fine-grained standards for each target using `target_compile_features`
7-
# Note: linking together projects compiled with different C++ standards may work, but
8-
# it is not recommended because of possible issues with ABI
3+
# Not ideal to use this global variable, but necessary to make sure
4+
# that tooling and projects use the same version
95
set(CMAKE_CXX_STANDARD 20)
106

117
# strongly encouraged to enable this globally to avoid conflicts between
128
# -Wpedantic being enabled and -std=c++20 and -std=gnu++20 for example
139
# when compiling with PCH enabled
1410
set(CMAKE_CXX_EXTENSIONS OFF)
1511

12+
13+
# Note: by default ENABLE_DEVELOPER_MODE is True
14+
# This means that all analysis (sanitizers, static analysis)
15+
# is enabled and all warnings are treated as errors
16+
# if you want to switch this behavior, change TRUE to FALSE
17+
set(ENABLE_DEVELOPER_MODE TRUE CACHE BOOL "Enable 'developer mode'")
18+
19+
# Change this to false if you want to disable warnings_as_errors in developer mode
20+
set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT TRUE)
21+
1622
# Add project_options v0.15.1
1723
# https://github.com/cpp-best-practices/project_options
1824
include(FetchContent)
@@ -26,7 +32,12 @@ include(${_project_options_SOURCE_DIR}/Index.cmake)
2632
# run_vcpkg()
2733

2834
# Set the project name and language
29-
project(myproject LANGUAGES CXX C)
35+
project(
36+
myproject
37+
VERSION 0.0.1
38+
DESCRIPTION "Starter Project With Best Practices for C++"
39+
HOMEPAGE_URL "https://github.com/cpp-best-practices/cpp_boilerplate_project"
40+
LANGUAGES CXX C)
3041

3142
get_property(BUILDING_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
3243
if(BUILDING_MULTI_CONFIG)
@@ -79,6 +90,11 @@ dynamic_project_options(
7990

8091
target_compile_features(project_options INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
8192

93+
# configure files based on CMake configuration options
94+
add_subdirectory(configured_files)
95+
target_include_directories(project_options INTERFACE "${CMAKE_BINARY_DIR}")
96+
97+
8298
# Adding the src:
8399
add_subdirectory(src)
84100

0 commit comments

Comments
 (0)