Skip to content

Commit

Permalink
[INFRA] Try CPM
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Nov 8, 2023
1 parent c486df3 commit 7432161
Show file tree
Hide file tree
Showing 26 changed files with 271 additions and 163 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
5 changes: 2 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,6 @@ jobs:
cmake ../test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DHIBF_NATIVE_BUILD=OFF \
-DHIBF_VERBOSE_TESTS=OFF
make -j2 gtest_build
- 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
5 changes: 2 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,6 @@ jobs:
-DHIBF_NATIVE_BUILD=OFF \
-DHIBF_VERBOSE_TESTS=OFF \
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
make -j2 gtest_build
- name: Build tests
run: |
Expand Down
5 changes: 2 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,6 @@ jobs:
cmake ../test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DHIBF_NATIVE_BUILD=OFF \
-DHIBF_VERBOSE_TESTS=OFF
make -j3 gtest_build
- name: Build tests
run: |
Expand Down
10 changes: 2 additions & 8 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 @@ -91,12 +91,6 @@ jobs:
-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;;
esac
- name: Check cyclic includes
if: matrix.use_include_dependencies == 'ON'
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})
48 changes: 27 additions & 21 deletions cmake/configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,32 @@ message (STATUS "Finding HIBF (${HIBF_VERSION}) and checking requirements")
# Includes
# ----------------------------------------------------------------------------

# Use find_package by default, unless -DCPM_USE_LOCAL_PACKAGES=OFF is passed or environment variable is set.
if (NOT DEFINED $ENV{CPM_USE_LOCAL_PACKAGES})
option (CPM_USE_LOCAL_PACKAGES "" ON)
endif ()
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)

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

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 +53,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 +277,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 +307,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 +316,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 +337,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
23 changes: 23 additions & 0 deletions cmake/hibf-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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

@PACKAGE_INIT@

include (CMakeFindDependencyMacro)
find_dependency (cereal @HIBF_CEREAL_VERSION@ REQUIRED)

find_package (PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_check_modules (simde QUIET simde>=@HIBF_SIMDE_VERSION@)
endif ()

if (simde_FOUND)
add_library (simde IMPORTED INTERFACE)
add_library (simde::simde ALIAS simde)
target_include_directories (simde INTERFACE ${simde_INCLUDEDIR})
else ()
find_dependency (simde @HIBF_SIMDE_VERSION@ REQUIRED)
endif ()

include ("${CMAKE_CURRENT_LIST_DIR}/hibf-targets.cmake")
Loading

0 comments on commit 7432161

Please sign in to comment.