Add CPM_SOURCE_CACHE environmental variable support and keep existing sources (#83)

* read CPM_SOURCE_CACHE from environment

* update readme

* cleanup

* add cache tests
This commit is contained in:
Lars Melchior
2019-10-10 20:13:10 +02:00
committed by GitHub
parent b1855e9275
commit 4064a45552
28 changed files with 300 additions and 58 deletions

1
test/unit/cache/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/CMakeLists.txt

30
test/unit/cache/CMakeLists.txt.in vendored Normal file
View File

@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(CPMExampleCatch2)
# ---- Options ----
option(ENABLE_TEST_COVERAGE "Enable test coverage" OFF)
# ---- Dependencies ----
include(@CPM_PATH@/CPM.cmake)
CPMAddPackage(
NAME fibonacci
GIT_REPOSITORY https://github.com/TheLartians/Fibonacci.git
VERSION 1.0
)
CPMAddPackage(
NAME Catch2
GITHUB_REPOSITORY catchorg/Catch2
VERSION @CATCH2_VERSION@
GIT_SHALLOW YES
)
# ---- Create binary ----
add_executable(CPMExampleCatch2 main.cpp)
target_link_libraries(CPMExampleCatch2 fibonacci Catch2)
set_target_properties(CPMExampleCatch2 PROPERTIES CXX_STANDARD 17 COMPILE_FLAGS "-Wall -pedantic -Wextra -Werror")

13
test/unit/cache/main.cpp vendored Normal file
View File

@@ -0,0 +1,13 @@
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <fibonacci.h>
TEST_CASE("fibonnacci"){
REQUIRE(fibonnacci(0) == 0);
REQUIRE(fibonnacci(1) == 1);
REQUIRE(fibonnacci(2) == 1);
REQUIRE(fibonnacci(3) == 2);
REQUIRE(fibonnacci(4) == 3);
REQUIRE(fibonnacci(5) == 5);
}