Skip to content

Commit

Permalink
[INFRA] Use CPM
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Nov 9, 2023
1 parent c486df3 commit 77281db
Show file tree
Hide file tree
Showing 29 changed files with 303 additions and 167 deletions.
70 changes: 70 additions & 0 deletions .cmake-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,76 @@ parse:
pargs: 1
kwargs:
CYCLIC_DEPENDING_INCLUDES: '+'
cpmgetpackage:
pargs: 1
spelling: CPMGetPackage
cpmaddpackage:
pargs:
nargs: '*'
flags: []
spelling: CPMAddPackage
kwargs: &cpmaddpackagekwargs
NAME: 1
FORCE: 1
VERSION: 1
GIT_TAG: 1
DOWNLOAD_ONLY: 1
GITHUB_REPOSITORY: 1
GITLAB_REPOSITORY: 1
GIT_REPOSITORY: 1
SVN_REPOSITORY: 1
SVN_REVISION: 1
SOURCE_DIR: 1
DOWNLOAD_COMMAND: 1
FIND_PACKAGE_ARGUMENTS: 1
NO_CACHE: 1
GIT_SHALLOW: 1
URL: 1
URL_HASH: 1
URL_MD5: 1
DOWNLOAD_NAME: 1
DOWNLOAD_NO_EXTRACT: 1
HTTP_USERNAME: 1
HTTP_PASSWORD: 1
EXCLUDE_FROM_ALL: 1
SYSTEM: 1
SOURCE_SUBDIR: 1
OPTIONS: +
cpmfindpackage:
pargs:
nargs: '*'
flags: []
spelling: CPMFindPackage
kwargs: *cpmaddpackagekwargs
cpmdeclarepackage:
pargs:
nargs: '*'
flags: []
spelling: CPMDeclarePackage
kwargs: *cpmaddpackagekwargs
packageproject:
pargs:
nargs: '*'
flags: []
spelling: packageProject
kwargs:
NAME: 1
VERSION: 1
INCLUDE_DIR: 1
INCLUDE_DESTINATION: 1
BINARY_DIR: 1
COMPATIBILITY: 1
VERSION_HEADER: 1
DEPENDENCIES: +
cpmusepackagelock:
pargs: 1
spelling: CPMUsePackageLock
cpmregisterpackage:
pargs: 1
spelling: CPMRegisterPackage
cpmgetpackageversion:
pargs: 2
spelling: CPMGetPackageVersion
_help_override_spec:
- Override configurations per-command where available
override_spec: {}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: ${{ steps.fetch_depth.outputs.depth }}
submodules: true
submodules: false

- name: Setup toolchain
uses: seqan/actions/setup-toolchain@main
Expand All @@ -60,7 +60,7 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.16.9
cmake: 3.18.6

- name: Install gcovr
run: |
Expand All @@ -74,7 +74,7 @@ jobs:
cmake ../test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DHIBF_NATIVE_BUILD=OFF \
-DHIBF_VERBOSE_TESTS=OFF
make -j2 gtest_build
make -j2 gtest_main
- name: Build tests
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
submodules: false

- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.16.9
cmake: 3.18.6

- name: Install Doxygen
uses: seqan/actions/setup-doxygen@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
submodules: false
path: hibf
token: ${{ secrets.SEQAN_ACTIONS_PAT }}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
submodules: false

- name: Setup toolchain
uses: seqan/actions/setup-toolchain@main
Expand All @@ -80,7 +80,7 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.16.9
cmake: 3.18.6

- name: Configure tests
run: |
Expand All @@ -90,7 +90,7 @@ jobs:
-DHIBF_NATIVE_BUILD=OFF \
-DHIBF_VERBOSE_TESTS=OFF \
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
make -j2 gtest_build
make -j2 gtest_main
- name: Build tests
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
submodules: false

- name: Setup toolchain
uses: seqan/actions/setup-toolchain@main
Expand All @@ -65,7 +65,7 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.16.9
cmake: 3.18.6

- name: Configure tests
run: |
Expand All @@ -74,7 +74,7 @@ jobs:
cmake ../test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DHIBF_NATIVE_BUILD=OFF \
-DHIBF_VERBOSE_TESTS=OFF
make -j3 gtest_build
make -j3 gtest_main
- name: Build tests
run: |
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/ci_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
submodules: false

- name: Setup toolchain
uses: seqan/actions/setup-toolchain@main
Expand All @@ -80,7 +80,7 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.16.9
cmake: 3.18.6

- name: Configure tests
run: |
Expand All @@ -89,13 +89,12 @@ jobs:
cmake ../test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DHIBF_NATIVE_BUILD=OFF \
-DHIBF_VERBOSE_TESTS=OFF \
-DHIBF_BENCHMARK_MIN_TIME=0.01 \
-DHIBF_USE_INCLUDE_DEPENDENCIES="${{ matrix.use_include_dependencies }}"
case "${{ matrix.build }}" in
unit) make -j2 gtest_build;;
snippet) make -j2 gtest_build;;
performance) make -j2 gbenchmark_build;;
header) make -j2 gtest_build gbenchmark_build;;
unit) make -j2 gtest_main;;
snippet) make -j2 gtest_main;;
performance) make -j2 benchmark_main;;
header) make -j2 gtest_main benchmark_main;;
esac
- name: Check cyclic includes
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
submodules: false

- name: Setup toolchain
uses: seqan/actions/setup-toolchain@main
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
cmake: 3.16.9
cmake: 3.18.6

- name: Configure util
run: |
Expand Down
10 changes: 0 additions & 10 deletions .gitmodules

This file was deleted.

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

set (CPM_DOWNLOAD_VERSION 0.38.6)
set (CPM_HASH_SUM "11c3fa5f1ba14f15d31c2fb63dbc8628ee133d81c8d764caad9a8db9e0bacb07")

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})
44 changes: 23 additions & 21 deletions cmake/configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,28 @@ message (STATUS "Finding HIBF (${HIBF_VERSION}) and checking requirements")
# Includes
# ----------------------------------------------------------------------------

set (CPM_INDENT " CMake Package Manager CPM: ")
include (${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
CPMUsePackageLock (${CMAKE_CURRENT_LIST_DIR}/package-lock.cmake)

include (CheckIncludeFileCXX)
include (CheckCXXSourceCompiles)
include (CheckCXXSourceRuns)
include (CheckCXXCompilerFlag)

# ----------------------------------------------------------------------------
# Find or add dependencies
# ----------------------------------------------------------------------------

CPMGetPackage (cereal)

if (cereal_ADDED)
set_target_properties (cereal PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
$<TARGET_PROPERTY:cereal,INTERFACE_INCLUDE_DIRECTORIES>)
endif ()

include (${CMAKE_CURRENT_LIST_DIR}/simde.cmake)

# ----------------------------------------------------------------------------
# Pretty printing and error handling
# ----------------------------------------------------------------------------
Expand All @@ -32,30 +49,14 @@ macro (hibf_config_error text)

endmacro ()

# ----------------------------------------------------------------------------
# Add submodules
# ----------------------------------------------------------------------------

set (HIBF_SUBMODULES_DIR
"${HIBF_SOURCE_DIR}"
CACHE STRING "Directory containing submodules.")
file (GLOB submodules ${HIBF_SUBMODULES_DIR}/submodules/*/include ${HIBF_SUBMODULES_DIR}/submodules/simde
${HIBF_SUBMODULES_DIR}/simde)
foreach (submodule ${submodules})
if (IS_DIRECTORY ${submodule})
hibf_config_print (" …adding submodule include: ${submodule}")
set (HIBF_DEPENDENCY_HEADER_PATHS ${submodule} ${HIBF_DEPENDENCY_HEADER_PATHS})
endif ()
endforeach ()

# ----------------------------------------------------------------------------
# Options for CheckCXXSourceCompiles
# ----------------------------------------------------------------------------

# deactivate messages in check_*
set (CMAKE_REQUIRED_QUIET 1)
# use global variables in Check* calls
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH} ${HIBF_HEADER_PATH} ${HIBF_DEPENDENCY_HEADER_PATHS})
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH} ${HIBF_HEADER_PATH})
set (CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS})

# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -272,7 +273,7 @@ if (Threads_FOUND)
if ("${CMAKE_THREAD_LIBS_INIT}" STREQUAL "")
hibf_config_print ("Thread support: builtin")
else ()
set (HIBF_LIBRARIES ${HIBF_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
list (APPEND HIBF_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
hibf_config_print ("Thread support: via ${CMAKE_THREAD_LIBS_INIT}")
endif ()
else ()
Expand Down Expand Up @@ -302,7 +303,7 @@ unset (HIBF_ROBIN_HOOD_DIR)
if ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
OR (${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
OR (${CMAKE_SYSTEM_NAME} STREQUAL "GNU"))
set (HIBF_LIBRARIES ${HIBF_LIBRARIES} rt)
list (APPEND HIBF_LIBRARIES "rt")
endif ()

# libexecinfo -- implicit
Expand All @@ -311,7 +312,8 @@ mark_as_advanced (_HIBF_HAVE_EXECINFO)
if (_HIBF_HAVE_EXECINFO)
hibf_config_print ("Optional dependency: libexecinfo found")
if ((${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") OR (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD"))
set (HIBF_LIBRARIES ${HIBF_LIBRARIES} execinfo elf)
list (APPEND HIBF_LIBRARIES "execinfo")
list (APPEND HIBF_LIBRARIES "elf")
endif ()
else ()
hibf_config_print ("Optional dependency: libexecinfo not found")
Expand All @@ -331,7 +333,7 @@ try_compile (HIBF_PLATFORM_TEST #
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${CMAKE_CXX_FLAGS} ${HIBF_CXX_FLAGS}"
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${HIBF_HEADER_PATH};${HIBF_DEPENDENCY_HEADER_PATHS}"
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${HIBF_HEADER_PATH}"
COMPILE_DEFINITIONS ${HIBF_DEFINITIONS}
LINK_LIBRARIES ${HIBF_LIBRARIES}
OUTPUT_VARIABLE HIBF_PLATFORM_TEST_OUTPUT)
Expand Down
16 changes: 15 additions & 1 deletion cmake/cpack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ set (CPACK_RESOURCE_FILE_README "${HIBF_SOURCE_DIR}/README.md")

# Source Package
set (CPACK_SOURCE_GENERATOR "TXZ")
set (CPACK_SOURCE_IGNORE_FILES "\\\\.git($|/)")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\.git($|/)")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\.github/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\.vscode/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/build/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/submodules/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/cmake/CPM.cmake")

# Already being called on source package
if (NOT CPM_DOWNLOAD_LOCATION)
set (CPM_DOWNLOAD_LOCATION "${HIBF_SOURCE_DIR}/cmake/CPM.cmake")
endif ()

configure_file ("${HIBF_SOURCE_DIR}/cmake/cpack_install.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cpack_install.cmake"
@ONLY)
set (CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/cpack_install.cmake")

include (CPack)
7 changes: 7 additions & 0 deletions cmake/cpack_install.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin
# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik
# SPDX-License-Identifier: BSD-3-Clause

if (CPACK_SOURCE_INSTALLED_DIRECTORIES)
configure_file ("@CPM_DOWNLOAD_LOCATION@" "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake" COPYONLY)
endif ()
Loading

0 comments on commit 77281db

Please sign in to comment.