-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from pasbi/add-tests-ci
Create cmake-multi-platform.yml
- Loading branch information
Showing
7 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. | ||
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml | ||
name: CMake on multiple platforms | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
env: | ||
CONAN_HOME: "${{ github.workspace }}/.conan2" | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | ||
fail-fast: false | ||
|
||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
compiler: [gcc, msvc] | ||
build_type: [Release] | ||
exclude: | ||
- os: windows-latest | ||
compiler: gcc | ||
- os: ubuntu-latest | ||
compiler: msvc | ||
include: | ||
- compiler: gcc | ||
generator: "Unix Makefiles" | ||
cppstd: gnu20 | ||
libcxx: libstdc++ | ||
compiler_version: 11 | ||
- compiler: msvc | ||
generator: "Visual Studio 17 2022" | ||
cppstd: 20 | ||
compiler_runtime: dynamic | ||
compiler_version: 194 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- if: ${{ matrix.os == 'ubuntu-latest' }} | ||
run: sudo apt-get update; sudo apt-get install ninja-build | ||
|
||
- name: Install Conan | ||
id: conan | ||
uses: turtlebrowser/get-conan@main | ||
|
||
- name: Conan version | ||
run: echo "${{ steps.conan.outputs.version }}" | ||
|
||
- name: Cache Conan Dependencies | ||
id: cache-conan | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.CONAN_HOME }} | ||
key: conan-cache-${{ runner.os }}-${{ hashFiles('conanfile.py') }} | ||
restore-keys: conan-cache-${{ runner.os }}- | ||
|
||
- uses: DamianReeves/write-file-action@master | ||
if: ${{ matrix.os == 'ubuntu-latest' }} | ||
with: | ||
path: ${{ env.CONAN_HOME }}/profiles/default | ||
contents: | | ||
[settings] | ||
arch=x86_64 | ||
build_type=${{ matrix.build_type }} | ||
compiler=${{ matrix.compiler }} | ||
compiler.cppstd=${{ matrix.cppstd }} | ||
compiler.version=${{ matrix.compiler_version }} | ||
os=${{ runner.os }} | ||
compiler.libcxx=${{ matrix.libcxx }} | ||
[conf] | ||
tools.system.package_manager:mode=install | ||
tools.system.package_manager:sudo=True | ||
write-mode: append | ||
|
||
- uses: DamianReeves/write-file-action@master | ||
if: ${{ matrix.os == 'windows-latest' }} | ||
with: | ||
path: ${{ env.CONAN_HOME }}/profiles/default | ||
contents: | | ||
[settings] | ||
arch=x86_64 | ||
build_type=${{ matrix.build_type }} | ||
compiler=${{ matrix.compiler }} | ||
compiler.cppstd=${{ matrix.cppstd }} | ||
compiler.version=${{ matrix.compiler_version }} | ||
os=${{ runner.os }} | ||
compiler.runtime=${{ matrix.compiler_runtime }} | ||
write-mode: append | ||
|
||
|
||
- name: PrintProfile | ||
run: cat ${{ env.CONAN_HOME }}/profiles/default | ||
|
||
- name: list packages | ||
if: ${{ matrix.os == 'ubuntu-latest' }} | ||
run: dpkg --list | ||
|
||
- name: Install Dependencies | ||
run: conan install . --build=missing --output-folder=build | ||
|
||
- name: Build | ||
run: | | ||
cmake -G "${{ matrix.generator }}" -S . -B build -DCMAKE_TOOLCHAIN_FILE="build/build/generators/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
cmake --build build --config ${{ matrix.build_type }} --parallel | ||
- name: Test | ||
run: ctest --build-config ${{ matrix.build_type }} --test-dir build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "googletest"] | ||
path = googletest | ||
url = [email protected]:google/googletest.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from conan import ConanFile | ||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps | ||
|
||
|
||
class TireRecipe(ConanFile): | ||
name = "tire" | ||
version = "1.0" | ||
|
||
# Optional metadata | ||
license = "<Put the package license here>" | ||
author = "<Put your name here> <And your email here>" | ||
url = "<Package recipe repository url here, for issues about the package>" | ||
description = "<Description of hello package here>" | ||
topics = ("<Put some tag here>", "<here>", "<and here>") | ||
|
||
# Binary configuration | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False], "fPIC": [True, False]} | ||
default_options = {"shared": False, "fPIC": True} | ||
|
||
# Sources are located in the same place as this recipe, copy them to the recipe | ||
exports_sources = "CMakeLists.txt", "src/*", "include/*", "test/*" | ||
|
||
def requirements(self): | ||
self.requires("qt/[>=6.4]", options={ | ||
"openssl": False, | ||
"with_pq": False, | ||
"with_md4c": False, | ||
"with_odbc": False, | ||
"with_brotli": False, | ||
"with_libpng": False, | ||
"with_sqlite3": True, | ||
"shared": True, | ||
}) | ||
self.requires("spdlog/[>=1.14]") | ||
self.requires("nlohmann_json/[>=3.0]") | ||
self.requires("fmt/[>=10.0]") | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def generate(self): | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
tc = CMakeToolchain(self) | ||
tc.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["hello"] |
Submodule googletest
added at
0953a1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
include(GoogleTest) | ||
add_executable(tests | ||
test.cpp | ||
) | ||
target_link_libraries(tests PRIVATE GTest::gtest_main) | ||
gtest_discover_tests(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <gtest/gtest.h> | ||
|
||
// Demonstrate some basic assertions. | ||
TEST(HelloTest, BasicAssertions) { | ||
// Expect two strings not to be equal. | ||
EXPECT_STRNE("hello", "world"); | ||
// Expect equality. | ||
EXPECT_EQ(7 * 6, 42); | ||
} | ||
|