Skip to content

Commit b1f094d

Browse files
authored
Feat fetch content (#43)
1 parent 6d5285a commit b1f094d

File tree

14 files changed

+36
-53
lines changed

14 files changed

+36
-53
lines changed

.github/workflows/ci.yml

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ jobs:
3636
steps:
3737
- name: Checkout Code
3838
uses: actions/checkout@v2
39-
with:
40-
submodules: true
4139

4240
- name: Configure (${{ matrix.configuration }})
4341
run: cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }}

.gitmodules

-3
This file was deleted.

CMakeLists.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# This file specifies how the project should be built, using CMake.
22
# If you are unfamiliar with CMake, don't worry about all the details.
3-
# The sections you might want to edit are marked as such, and
3+
# The sections you might want to edit are marked as such, and
44
# the comments should hopefully make most of it clear.
55
#
66
# For many purposes, you may not need to change anything about this file.
77

8-
cmake_minimum_required(VERSION 3.12)
8+
cmake_minimum_required(VERSION 3.14)
99

1010
# Set project name, version and laguages here. (change as needed)
11-
# Version numbers are available by including "exampleConfig.h" in
11+
# Version numbers are available by including "exampleConfig.h" in
1212
# the source. See exampleConfig.h.in for some more details.
1313
project(CPP_BOILERPLATE VERSION 1.2.3.4 LANGUAGES CXX)
1414

@@ -70,10 +70,10 @@ target_enable_lto(main optimized) # enable link-time-optimization if available
7070

7171
# Set the properties you require, e.g. what C++ standard to use. Here applied to library and main (change as needed).
7272
set_target_properties(
73-
${LIBRARY_NAME} main
74-
PROPERTIES
75-
CXX_STANDARD 17
76-
CXX_STANDARD_REQUIRED YES
73+
${LIBRARY_NAME} main
74+
PROPERTIES
75+
CXX_STANDARD 17
76+
CXX_STANDARD_REQUIRED YES
7777
CXX_EXTENSIONS NO
7878
)
7979

README.md

+6-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/bsamseth/cpp-project.svg)](http://isitmaintained.com/project/bsamseth/cpp-project "Average time to resolve an issue")
1212
[![Percentage of issues still open](http://isitmaintained.com/badge/open/bsamseth/cpp-project.svg)](http://isitmaintained.com/project/bsamseth/cpp-project "Percentage of issues still open")
1313

14-
# Boiler plate for C++ projects
14+
# Boiler plate for C++ projects
1515

1616
This is a boiler plate for C++ projects. What you get:
1717

@@ -41,16 +41,16 @@ This is a boiler plate for C++ projects. What you get:
4141
```
4242

4343
Sources go in [src/](src/), header files in [include/](include/), main programs in [app/](app), and
44-
tests go in [tests/](tests/) (compiled to `unit_tests` by default).
44+
tests go in [tests/](tests/) (compiled to `unit_tests` by default).
4545

46-
If you add a new executable, say `app/hello.cpp`, you only need to add the following two lines to [CMakeLists.txt](CMakeLists.txt):
46+
If you add a new executable, say `app/hello.cpp`, you only need to add the following two lines to [CMakeLists.txt](CMakeLists.txt):
4747

4848
``` cmake
4949
add_executable(main app/main.cpp) # Name of exec. and location of file.
5050
target_link_libraries(main PRIVATE ${LIBRARY_NAME}) # Link the executable to lib built from src/*.cpp (if it uses it).
5151
```
5252

53-
You can find the example source code that builds the `main` executable in [app/main.cpp](app/main.cpp) under the `Build` section in [CMakeLists.txt](CMakeLists.txt).
53+
You can find the example source code that builds the `main` executable in [app/main.cpp](app/main.cpp) under the `Build` section in [CMakeLists.txt](CMakeLists.txt).
5454
If the executable you made does not use the library in [src/](src), then only the first line is needed.
5555

5656

@@ -89,20 +89,12 @@ upload this to Coveralls.io and/or Codecov.io
8989
### Using the GitHub template
9090
Click the `Use this template` button to make a new repository from this template.
9191

92-
**NB**: GitHub templates do not carry over submodules, which means you need to add those back _before_ you can build the project. Run the following after you have generated your new project:
93-
``` bash
94-
> git clone https://github.com/<your-username>/<your-repo-name>
95-
> git submodule add https://github.com/onqtam/doctest.git external/doctest
96-
> git commit -a --amend --no-edit
97-
> git push --force
98-
```
99-
10092
### From command line
10193
When starting a new project, you probably don't want the history of this repository. To start fresh you can use
10294
the [setup script](setup.sh) as follows:
10395
``` bash
104-
> git clone --recurse-submodules https://github.com/bsamseth/cpp-project # Or use ssh-link if you like.
96+
> git clone https://github.com/bsamseth/cpp-project # Or use ssh-link if you like.
10597
> cd cpp-project
10698
> bash setup.sh
10799
```
108-
The result is a fresh Git repository with one commit adding all files from the boiler plate.
100+
The result is a fresh Git repository with one commit adding all files from the boiler plate.

app/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// users, this can be left out.
44
#ifdef ENABLE_DOCTEST_IN_LIBRARY
55
#define DOCTEST_CONFIG_IMPLEMENT
6-
#include "doctest.h"
6+
#include "doctest/doctest.h"
77
#endif
88

99
#include <iostream>

appveyor.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ platform:
1414
configuration:
1515
- Debug
1616
- Release
17-
17+
1818
# environment:
1919
# matrix:
2020
# - TOOLSET: v140
21-
21+
2222
matrix:
2323
fast_finish: false
2424

@@ -27,20 +27,16 @@ init:
2727
- cmd: cmake --version
2828
- cmd: msbuild /version
2929

30-
install:
31-
- git submodule update --init --recursive
32-
3330
before_build:
3431
- cmake . -Bbuild -A%PLATFORM% -DCMAKE_BUILD_TYPE=%configuration%
3532

3633
build:
3734
project: build/CPP_BOILERPLATE.sln
3835
parallel: true
3936
verbosity: minimal
40-
37+
4138
test_script:
4239
- cd build
4340
- set CTEST_OUTPUT_ON_FAILURE=1
44-
- ctest -C %configuration%
41+
- ctest -C %configuration%
4542
- cd ..
46-

cmake/Doctest.cmake

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
if(ENABLE_DOCTESTS)
22
add_definitions(-DENABLE_DOCTEST_IN_LIBRARY)
3-
endif()
3+
include(FetchContent)
4+
FetchContent_Declare(
5+
DocTest
6+
GIT_REPOSITORY "https://github.com/onqtam/doctest"
7+
GIT_TAG "932a2ca50666138256dae56fbb16db3b1cae133a"
8+
)
49

5-
add_library(doctest INTERFACE)
6-
target_include_directories(doctest INTERFACE ${PROJECT_SOURCE_DIR}/external/doctest/doctest)
10+
FetchContent_MakeAvailable(DocTest)
11+
include_directories(${DOCTEST_INCLUDE_DIR})
12+
endif()

external/doctest

-1
This file was deleted.

include/example.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Dummy {
1919

2020

2121
#ifdef ENABLE_DOCTEST_IN_LIBRARY
22-
#include "doctest.h"
22+
#include "doctest/doctest.h"
2323
TEST_CASE("we can have tests in headers if we want")
2424
{
2525
Dummy d;

setup.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ email=$(git config user.email)
1111
if [[ "$1" ]]; then
1212
git commit --amend --author="$1"
1313
else
14-
git commit --amend --author="$name <$email>"
14+
git commit --amend --author="$name <$email>"
1515
fi
1616

17-
# Initialize submodules: This should already be done when cloning, but there are ways to muck it
18-
# up if you do things in the wrong order. So just to be sure, we do it now.
19-
git submodule update --init --recursive
20-
2117
# Remove the remote (you probably want your own instead).
2218
git remote remove origin

src/example.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bool Dummy::doSomething() {
1313

1414

1515
#ifdef ENABLE_DOCTEST_IN_LIBRARY
16-
#include "doctest.h"
16+
#include "doctest/doctest.h"
1717
TEST_CASE("we can have tests written here, to test impl. details")
1818
{
1919
CHECK(true);

tests/CMakeLists.txt

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.12)
1+
cmake_minimum_required(VERSION 3.14)
22

33
# List all files containing tests. (Change as needed)
44
set(TESTFILES # All .cpp files in tests/
@@ -17,9 +17,9 @@ target_link_libraries(${TEST_MAIN} PRIVATE ${LIBRARY_NAME} doctest)
1717
set_target_properties(${TEST_MAIN} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
1818
target_set_warnings(${TEST_MAIN} ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
1919

20-
set_target_properties(${TEST_MAIN} PROPERTIES
21-
CXX_STANDARD 17
22-
CXX_STANDARD_REQUIRED YES
20+
set_target_properties(${TEST_MAIN} PROPERTIES
21+
CXX_STANDARD 17
22+
CXX_STANDARD_REQUIRED YES
2323
CXX_EXTENSIONS NO
2424
)
2525

@@ -30,4 +30,3 @@ add_test(
3030

3131
# Adds a 'coverage' target.
3232
include(CodeCoverage)
33-

tests/dummy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "doctest.h"
1+
#include "doctest/doctest.h"
22
#include "example.h"
33

44
// Tests that don't naturally fit in the headers/.cpp files directly

tests/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
2-
#include "doctest.h"
2+
#include "doctest/doctest.h"
33

44
// This is all that is needed to compile a test-runner executable.
55
// More tests can be added here, or in a new tests/*.cpp file.

0 commit comments

Comments
 (0)