Skip to content

Commit

Permalink
Merge pull request #4 from andreiavrammsd/cpm
Browse files Browse the repository at this point in the history
Use CPM dependency management
  • Loading branch information
andreiavrammsd authored Apr 17, 2023
2 parents 4b68dbb + a692392 commit 0b689e2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

strategy:
matrix:
os: [ ubuntu-18.04 ]
os: [ ubuntu-22.04 ]
compiler: [ gcc, clang ]

steps:
Expand Down
7 changes: 3 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "gtest",
url = "https://github.com/google/googletest/archive/release-1.10.0.zip",
sha256 = "94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91",
build_file = "@//:gtest.BUILD",
strip_prefix = "googletest-release-1.10.0",
url = "https://github.com/google/googletest/archive/v1.12.0.zip",
sha256 = "fbc8efdca4238e7dbe0642e29911a77be393f191a2444fa10372ee99bb665125",
strip_prefix = "googletest-1.12.0",
)
28 changes: 0 additions & 28 deletions gtest.BUILD

This file was deleted.

29 changes: 22 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror --coverage -fsanitize=undefined")

# CPM
set(CPM_DOWNLOAD_VERSION 0.38.1)

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()

include(${CPM_DOWNLOAD_LOCATION})

# Testing framework
include(FetchContent)
if (NOT googletest_POPULATED)
FetchContent_Declare(googletest URL https://github.com/google/googletest/archive/release-1.10.0.zip)
FetchContent_Populate(googletest)
include_directories(${googletest_SOURCE_DIR}/googletest/include/)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
endif ()
CPMAddPackage("gh:google/googletest@1.12.0")

# Test macro
macro(package_add_test TESTNAME)
Expand Down

0 comments on commit 0b689e2

Please sign in to comment.