Skip to content

Commit

Permalink
Merge pull request #77 from eseiler/infra/simplify
Browse files Browse the repository at this point in the history
[INFRA] Simplify
  • Loading branch information
eseiler authored Mar 13, 2024
2 parents 2d6439a + 0fb8d58 commit 110c346
Show file tree
Hide file tree
Showing 27 changed files with 197 additions and 395 deletions.
8 changes: 8 additions & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ parse:
_help_additional_commands:
- Specify structure for custom cmake functions
additional_commands:
declare_datasource:
pargs:
nargs: '*'
flags: []
kwargs:
FILE: 1
URL: '*'
URL_HASH: 1
cpmgetpackage:
pargs: 1
spelling: CPMGetPackage
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:
include:
- name: "gcc13"
compiler: "gcc-13"
build: coverage
build_type: Coverage

steps:
# How many commits do we need to fetch to also fetch the branch point?
Expand All @@ -56,7 +54,7 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.21.7
cmake: 3.25.3

- name: Install gcovr
run: |
Expand All @@ -67,12 +65,14 @@ jobs:
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake .. -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage -fprofile-arcs -ftest-coverage -Werror" \
-DCMAKE_C_FLAGS="--coverage -fprofile-arcs -ftest-coverage -Werror" \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-lgcov" \
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-lgcov"
make -j2 -k gtest_main yaml-cpp
- name: Build tests
env:
CCACHE_IGNOREOPTIONS: "-fprofile-abs-path"
run: |
ccache -z
cd build
Expand All @@ -82,7 +82,7 @@ jobs:
- name: Generate coverage report
run: |
gcovr --gcov-executable ${{ github.workspace }}/.github/workflows/scripts/gcov.sh \
--root ${{ github.workspace }}/test/coverage \
--root ${{ github.workspace }}/test \
${{ github.workspace }}/build \
--filter ${{ github.workspace }}/include \
--filter ${{ github.workspace }}/src \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
check:
name: REUSE Compliance
runs-on: ubuntu-22.04
timeout-minutes: 120
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.21.7
cmake: 3.25.3

- name: Configure
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }} -Werror"
make -j2 -k gtest_main yaml-cpp
- name: Build application
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.21.7
cmake: 3.25.3

- name: Configure
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }} -Werror"
make -j3 -k gtest_main yaml-cpp
- name: Build application
Expand Down
64 changes: 24 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,45 @@
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
# SPDX-License-Identifier: CC0-1.0

cmake_minimum_required (VERSION 3.16)

## CUSTOMISE
cmake_minimum_required (VERSION 3.25)

# Define the application name and version.
project (app-template VERSION 1.0.0)

# Needed for CPM
find_package (Git REQUIRED)

## BUILD

# Make Release default build type
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE
Release
CACHE STRING "Choose the type of build, options are: Debug Release Coverage RelWithDebInfo MinSizeRel." FORCE
)
endif ()
project (app-template
LANGUAGES CXX
VERSION 1.0.0
DESCRIPTION "My application description"
)

# Specify the directories where to store the built archives, libraries and executables
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

# Messages
string (ASCII 27 Esc)
set (FontBold "${Esc}[1m")
set (FontReset "${Esc}[m")

# Allow to include CMake scripts from the app-template.
# This allows including `*.cmake` files from the `cmake` directory without specifying the full path.
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

# Use ccache.
# Use ccache if available. This speeds up the build process by caching files that have been compiled before.
include (ccache)
require_ccache ()

# Specify the directories where to store the built archives, libraries and executables.
include (output_directories)

# Add packages.
set (CPM_INDENT " CMake Package Manager CPM: ")
# We use CPM for package management: https://github.com/cpm-cmake/CPM.cmake
# The added packages (hibf, sharg, seqan3) are defined in the `cmake/package-locj.cmake` file.
include (CPM)
include (CPMGetSystemPackage)
CPMUsePackageLock (${CMAKE_CURRENT_LIST_DIR}/cmake/package-lock.cmake)

CPMGetSystemPackage (hibf)
CPMGetSystemPackage (sharg)
CPMGetSystemPackage (seqan3)
CPMGetPackage (hibf)
CPMGetPackage (sharg)
CPMGetPackage (seqan3)

# Add the application.
# Add the application. This will include `src/CMakeLists.txt`.
add_subdirectory (src)
message (STATUS "${FontBold}You can run `make` to build the application.${FontReset}")

## TEST
# An option to disable configuring and building the tests. Tests are enabled by default.
# If your project-name (line 8 of this file) is `app-template`, the option will be `app-template_TEST`.
# It can be used when calling CMake: `cmake .. -Dapp-template_TEST=OFF`.
# It is good practice to allow disabling tests. If another project includes your application,
# it might not want to build your tests.
option (${PROJECT_NAME}_TEST "Enable testing for ${PROJECT_NAME}." ON)

if (${PROJECT_NAME}_TEST)
list (APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") # Must be before `enable_testing ()`.
enable_testing ()
# Add the tests. This will include `test/CMakeLists.txt`.
add_subdirectory (test EXCLUDE_FROM_ALL)
endif ()
11 changes: 0 additions & 11 deletions LICENSES/BSD-3-Clause.txt

This file was deleted.

30 changes: 0 additions & 30 deletions cmake/CPMGetSystemPackage.cmake

This file was deleted.

33 changes: 13 additions & 20 deletions cmake/ccache.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required (VERSION 3.21)
# SPDX-License-Identifier: CC0-1.0

include (FindPackageMessage)

Expand All @@ -11,25 +9,20 @@ include (FindPackageMessage)
# See also
# * https://ccache.dev/
# * https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html
macro (require_ccache)
option (USE_CCACHE "Use ccache if available." ON)
set (FPROFILE_ABS_PATH "-fprofile-abs-path")
if (USE_CCACHE)
find_program (CCACHE_PROGRAM ccache)
option (USE_CCACHE "Use ccache if available." ON)

if (NOT CCACHE_PROGRAM)
find_package_message (CCACHE_PROGRAM " Ccache program: not available" "[${CCACHE_PROGRAM}]")
else ()
find_package_message (CCACHE_PROGRAM " Ccache program: available" "[${CCACHE_PROGRAM}]")
set (FPROFILE_ABS_PATH "--ccache-skip -fprofile-abs-path")
if (USE_CCACHE)
find_program (CCACHE_PROGRAM ccache)

list (PREPEND CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
list (PREPEND CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
if (NOT CCACHE_PROGRAM)
find_package_message (CCACHE_PROGRAM "Ccache program: not available" "[${CCACHE_PROGRAM}]")
else ()
find_package_message (CCACHE_PROGRAM "Ccache program: available" "[${CCACHE_PROGRAM}]")

list (PREPEND CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_PROGRAM}")
list (PREPEND CMAKE_C_LINKER_LAUNCHER "${CCACHE_PROGRAM}")
endif ()
list (PREPEND CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
list (PREPEND CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")

unset (CCACHE_PROGRAM)
list (PREPEND CMAKE_CXX_LINKER_LAUNCHER "${CCACHE_PROGRAM}")
list (PREPEND CMAKE_C_LINKER_LAUNCHER "${CCACHE_PROGRAM}")
endif ()
endmacro ()
endif ()
7 changes: 7 additions & 0 deletions cmake/output_directories.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
# SPDX-License-Identifier: CC0-1.0

set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
4 changes: 4 additions & 0 deletions cmake/package-lock.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CPMDeclarePackage (hibf
GIT_TAG ${HIBF_VERSION}
GITHUB_REPOSITORY seqan/hibf
SYSTEM TRUE
EXCLUDE_FROM_ALL TRUE
OPTIONS "INSTALL_HIBF OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING"
)
# sharg
Expand All @@ -21,6 +22,7 @@ CPMDeclarePackage (sharg
GIT_TAG ${SHARG_VERSION}
GITHUB_REPOSITORY seqan/sharg-parser
SYSTEM TRUE
EXCLUDE_FROM_ALL TRUE
OPTIONS "INSTALL_SHARG OFF" "INSTALL_TDL OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING"
)
# seqan3
Expand All @@ -30,6 +32,7 @@ CPMDeclarePackage (seqan3
GIT_TAG ${SEQAN3_VERSION}
GITHUB_REPOSITORY seqan/seqan3
SYSTEM TRUE
EXCLUDE_FROM_ALL TRUE
OPTIONS "INSTALL_SEQAN3 OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING"
)
# googletest
Expand All @@ -39,5 +42,6 @@ CPMDeclarePackage (googletest
VERSION ${GOOGLETEST_VERSION}
GITHUB_REPOSITORY google/googletest
SYSTEM TRUE
EXCLUDE_FROM_ALL TRUE
OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING"
)
23 changes: 23 additions & 0 deletions cmake/test/add_local_data.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
# SPDX-License-Identifier: CC0-1.0

set (DATASOURCES_DATA_DIR "${${PROJECT_NAME}_SOURCE_DIR}/test/data")

file (GLOB_RECURSE datasources
LIST_DIRECTORIES false
RELATIVE ${DATASOURCES_DATA_DIR}
CONFIGURE_DEPENDS ${DATASOURCES_DATA_DIR}/*
)
list (REMOVE_ITEM datasources datasources.cmake README.md)
list (FILTER datasources EXCLUDE REGEX "\.license")

foreach (datasource IN LISTS datasources)
get_filename_component (datasource_name "${datasource}" NAME)
file (SHA256 ${DATASOURCES_DATA_DIR}/${datasource} datasource_hash)

declare_datasource (FILE ${datasource_name}
URL ${DATASOURCES_DATA_DIR}/${datasource}
URL_HASH SHA256=${datasource_hash}
)
endforeach ()
Loading

0 comments on commit 110c346

Please sign in to comment.