init
This commit is contained in:
commit
2f3a28e89c
10 changed files with 150 additions and 0 deletions
93
.gitignore
vendored
Normal file
93
.gitignore
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
### CMake template
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
CMakeUserPresets.json
|
||||
### CLion template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
.idea
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "test/Catch2"]
|
||||
path = test/Catch2
|
||||
url = https://github.com/catchorg/Catch2.git
|
8
CMakeLists.txt
Normal file
8
CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.31)
|
||||
|
||||
project(MyProject)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(test)
|
14
README.md
Normal file
14
README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# C++ Template with tests
|
||||
|
||||
A CMake template with C++20 and Catch2
|
||||
|
||||
---
|
||||
|
||||
## Setup
|
||||
|
||||
Under [test/Catch2](test/Catch2) run the following commands:
|
||||
|
||||
```shell
|
||||
$ cmake -B build -S . -DBUILD_TESTING=OFF
|
||||
$ sudo cmake --build build/ --target install
|
||||
```
|
3
src/CMakeLists.txt
Normal file
3
src/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
add_library(src STATIC library.cpp)
|
||||
|
||||
target_include_directories(src PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
5
src/library.cpp
Normal file
5
src/library.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include "library.h"
|
||||
|
||||
int hello() {
|
||||
return 0;
|
||||
}
|
6
src/library.h
Normal file
6
src/library.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef CPP_TEMPLATE_LIBRARY_H
|
||||
#define CPP_TEMPLATE_LIBRARY_H
|
||||
|
||||
int hello();
|
||||
|
||||
#endif //CPP_TEMPLATE_LIBRARY_H
|
7
test/CMakeLists.txt
Normal file
7
test/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
find_package(Catch2 3 REQUIRED)
|
||||
|
||||
add_executable(test test.cpp)
|
||||
|
||||
target_link_libraries(test PRIVATE Catch2::Catch2WithMain)
|
||||
|
||||
target_link_libraries(test PRIVATE src)
|
1
test/Catch2
Submodule
1
test/Catch2
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 3013cb897b5706e8532507cb2b6ac33e1fc35d93
|
10
test/test.cpp
Normal file
10
test/test.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include "library.h"
|
||||
|
||||
TEST_CASE("This test should pass") {
|
||||
REQUIRE(hello() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("This test should fail") {
|
||||
REQUIRE(hello() == 1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue