Skip to content

Commit

Permalink
❄️ flake support (dev shell & qolm target) (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierLDff authored Aug 20, 2024
1 parent aa23b09 commit 4aad491
Show file tree
Hide file tree
Showing 10 changed files with 372 additions and 26 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 👷 Nix CI

on:
push:
branches:
- main
tags:
- v*
pull_request:
types: [opened, synchronize, labeled]
workflow_dispatch:

jobs:
BuildNixFlake:
runs-on: ubuntu-latest

steps:
-
uses: naostage/nix-installer-action@10f43c0d327c8599928f907a943a737cff2505f3
-
uses: naostage/magic-nix-cache-action@1718a05c5e2bf6ac5d9b1b0ebd5fca6eaef2b923
with:
use-flakehub: false
-
uses: actions/checkout@v4
-
name: 🔨 Build Derivation
id: build
run: |
nix build .#qolm --print-build-logs
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
# Ignore CLion project files
*.idea
# For macOs users
.DS_Store
.DS_Store

# nix
result*
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ set(QOLM_PROJECT "QOlm" CACHE STRING "Project Name")
set(QOLM_TARGET ${QOLM_PROJECT} CACHE STRING "QOlm library name")
set(QOLM_VERBOSE ${QOLM_MAIN_PROJECT} CACHE BOOL "QOlm log configuration")

set(QOLM_BUILD_SHARED OFF CACHE BOOL "Build as a shared library (ON) or as static (OFF)")
set(QOLM_BUILD_SHARED ${BUILD_SHARED_LIBS} CACHE BOOL "Build as a shared library (ON) or as static (OFF)")
set(QOLM_FOLDER_PREFIX ${QOLM_PROJECT} CACHE STRING "Prefix folder for all QOlm generated targets in generated project (only decorative)")

# Tests
Expand Down
46 changes: 46 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

# Heuristic to check if file have already been found
if(COMMAND CpmAddPackage)
return()
endif()

if(QOLM_USE_LOCAL_CPM_FILE)
message(STATUS "Looking for local CPM.cmake")
find_file(CPM_LOCAL_FILE
CPM.cmake
PATH_SUFFIXES share/cpm/
)

if(EXISTS ${CPM_LOCAL_FILE})
message(STATUS "Using local CPM.cmake: ${CPM_LOCAL_FILE}")
include(${CPM_LOCAL_FILE})
return()
endif()
endif()

# Now the original from the release that can be found at
# https://github.com/cpm-cmake/CPM.cmake/releases

set(CPM_DOWNLOAD_VERSION 0.39.0)
set(CPM_HASH_SUM "66639bcac9dd2907b2918de466783554c1334446b9874e90d38e3778d404c2ef")

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()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
16 changes: 6 additions & 10 deletions cmake/FetchGTest.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
include(FetchContent)
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)

set(GTEST_REPOSITORY "https://github.com/OlivierLDff/googletest.git" CACHE STRING "googletest repository url")
set(GTEST_TAG "release-1.12.1" CACHE STRING "googletest git tag")
set(GTEST_TAG "v1.14.0" CACHE STRING "googletest git tag")

FetchContent_Declare(
googletest
CPMAddPackage(
NAME GTest
GIT_REPOSITORY ${GTEST_REPOSITORY}
GIT_TAG ${GTEST_TAG}
OPTIONS "gtest_force_shared_crt ON"
OPTIONS "INSTALL_GTEST OFF"
)

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" OFF)
FetchContent_MakeAvailable(googletest)

set_target_properties(gtest gtest_main gmock gmock_main PROPERTIES FOLDER "Dependencies/gtest")
12 changes: 0 additions & 12 deletions cmake/FetchQOlm.cmake

This file was deleted.

77 changes: 77 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4aad491

Please sign in to comment.