diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 915da19..862162a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,8 +36,6 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v2 - with: - submodules: true - name: Configure (${{ matrix.configuration }}) run: cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 2b9629c..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "external/doctest"] - path = external/doctest - url = https://github.com/onqtam/doctest.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 76ac583..03120d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,14 @@ # This file specifies how the project should be built, using CMake. # If you are unfamiliar with CMake, don't worry about all the details. -# The sections you might want to edit are marked as such, and +# The sections you might want to edit are marked as such, and # the comments should hopefully make most of it clear. # # For many purposes, you may not need to change anything about this file. -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.14) # Set project name, version and laguages here. (change as needed) -# Version numbers are available by including "exampleConfig.h" in +# Version numbers are available by including "exampleConfig.h" in # the source. See exampleConfig.h.in for some more details. project(CPP_BOILERPLATE VERSION 1.2.3.4 LANGUAGES CXX) @@ -70,10 +70,10 @@ target_enable_lto(main optimized) # enable link-time-optimization if available # Set the properties you require, e.g. what C++ standard to use. Here applied to library and main (change as needed). set_target_properties( - ${LIBRARY_NAME} main - PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED YES + ${LIBRARY_NAME} main + PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO ) diff --git a/README.md b/README.md index a9a19f1..4e8f633 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![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") [![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") -# Boiler plate for C++ projects +# Boiler plate for C++ projects This is a boiler plate for C++ projects. What you get: @@ -41,16 +41,16 @@ This is a boiler plate for C++ projects. What you get: ``` Sources go in [src/](src/), header files in [include/](include/), main programs in [app/](app), and -tests go in [tests/](tests/) (compiled to `unit_tests` by default). +tests go in [tests/](tests/) (compiled to `unit_tests` by default). -If you add a new executable, say `app/hello.cpp`, you only need to add the following two lines to [CMakeLists.txt](CMakeLists.txt): +If you add a new executable, say `app/hello.cpp`, you only need to add the following two lines to [CMakeLists.txt](CMakeLists.txt): ``` cmake add_executable(main app/main.cpp) # Name of exec. and location of file. target_link_libraries(main PRIVATE ${LIBRARY_NAME}) # Link the executable to lib built from src/*.cpp (if it uses it). ``` -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). +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). If the executable you made does not use the library in [src/](src), then only the first line is needed. @@ -89,20 +89,12 @@ upload this to Coveralls.io and/or Codecov.io ### Using the GitHub template Click the `Use this template` button to make a new repository from this template. -**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: -``` bash -> git clone https://github.com// -> git submodule add https://github.com/onqtam/doctest.git external/doctest -> git commit -a --amend --no-edit -> git push --force -``` - ### From command line When starting a new project, you probably don't want the history of this repository. To start fresh you can use the [setup script](setup.sh) as follows: ``` bash -> git clone --recurse-submodules https://github.com/bsamseth/cpp-project # Or use ssh-link if you like. +> git clone https://github.com/bsamseth/cpp-project # Or use ssh-link if you like. > cd cpp-project > bash setup.sh ``` -The result is a fresh Git repository with one commit adding all files from the boiler plate. +The result is a fresh Git repository with one commit adding all files from the boiler plate. diff --git a/app/main.cpp b/app/main.cpp index ed8b2fe..15fa772 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -3,7 +3,7 @@ // users, this can be left out. #ifdef ENABLE_DOCTEST_IN_LIBRARY #define DOCTEST_CONFIG_IMPLEMENT -#include "doctest.h" +#include "doctest/doctest.h" #endif #include diff --git a/appveyor.yml b/appveyor.yml index ba43afd..bfb21e1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,11 +14,11 @@ platform: configuration: - Debug - Release - + # environment: # matrix: # - TOOLSET: v140 - + matrix: fast_finish: false @@ -27,9 +27,6 @@ init: - cmd: cmake --version - cmd: msbuild /version -install: - - git submodule update --init --recursive - before_build: - cmake . -Bbuild -A%PLATFORM% -DCMAKE_BUILD_TYPE=%configuration% @@ -37,10 +34,9 @@ build: project: build/CPP_BOILERPLATE.sln parallel: true verbosity: minimal - + test_script: - cd build - set CTEST_OUTPUT_ON_FAILURE=1 - - ctest -C %configuration% + - ctest -C %configuration% - cd .. - diff --git a/cmake/Doctest.cmake b/cmake/Doctest.cmake index a75364a..ba86915 100644 --- a/cmake/Doctest.cmake +++ b/cmake/Doctest.cmake @@ -1,6 +1,12 @@ if(ENABLE_DOCTESTS) add_definitions(-DENABLE_DOCTEST_IN_LIBRARY) -endif() + include(FetchContent) + FetchContent_Declare( + DocTest + GIT_REPOSITORY "https://github.com/onqtam/doctest" + GIT_TAG "932a2ca50666138256dae56fbb16db3b1cae133a" + ) -add_library(doctest INTERFACE) -target_include_directories(doctest INTERFACE ${PROJECT_SOURCE_DIR}/external/doctest/doctest) + FetchContent_MakeAvailable(DocTest) + include_directories(${DOCTEST_INCLUDE_DIR}) +endif() diff --git a/external/doctest b/external/doctest deleted file mode 160000 index 503de03..0000000 --- a/external/doctest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 503de03ee2cbbfc58c2063dce36dc96f917f2da3 diff --git a/include/example.h b/include/example.h index eedb53a..63df249 100644 --- a/include/example.h +++ b/include/example.h @@ -19,7 +19,7 @@ class Dummy { #ifdef ENABLE_DOCTEST_IN_LIBRARY -#include "doctest.h" +#include "doctest/doctest.h" TEST_CASE("we can have tests in headers if we want") { Dummy d; diff --git a/setup.sh b/setup.sh index 26ccd31..eaa77cc 100755 --- a/setup.sh +++ b/setup.sh @@ -11,12 +11,8 @@ email=$(git config user.email) if [[ "$1" ]]; then git commit --amend --author="$1" else - git commit --amend --author="$name <$email>" + git commit --amend --author="$name <$email>" fi -# Initialize submodules: This should already be done when cloning, but there are ways to muck it -# up if you do things in the wrong order. So just to be sure, we do it now. -git submodule update --init --recursive - # Remove the remote (you probably want your own instead). git remote remove origin diff --git a/src/example.cpp b/src/example.cpp index ab5d7b5..90ad6b2 100644 --- a/src/example.cpp +++ b/src/example.cpp @@ -13,7 +13,7 @@ bool Dummy::doSomething() { #ifdef ENABLE_DOCTEST_IN_LIBRARY -#include "doctest.h" +#include "doctest/doctest.h" TEST_CASE("we can have tests written here, to test impl. details") { CHECK(true); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e5f4dcd..57639b5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.14) # List all files containing tests. (Change as needed) set(TESTFILES # All .cpp files in tests/ @@ -17,9 +17,9 @@ target_link_libraries(${TEST_MAIN} PRIVATE ${LIBRARY_NAME} doctest) set_target_properties(${TEST_MAIN} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) target_set_warnings(${TEST_MAIN} ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed). -set_target_properties(${TEST_MAIN} PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED YES +set_target_properties(${TEST_MAIN} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO ) @@ -30,4 +30,3 @@ add_test( # Adds a 'coverage' target. include(CodeCoverage) - diff --git a/tests/dummy.cpp b/tests/dummy.cpp index 045318b..db12b73 100644 --- a/tests/dummy.cpp +++ b/tests/dummy.cpp @@ -1,4 +1,4 @@ -#include "doctest.h" +#include "doctest/doctest.h" #include "example.h" // Tests that don't naturally fit in the headers/.cpp files directly diff --git a/tests/main.cpp b/tests/main.cpp index d2bc7a6..f54bc0e 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,5 +1,5 @@ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include "doctest.h" +#include "doctest/doctest.h" // This is all that is needed to compile a test-runner executable. // More tests can be added here, or in a new tests/*.cpp file.