Skip to content

Commit ca4680e

Browse files
committed
[INFRA] Use CPM
1 parent e0330d9 commit ca4680e

26 files changed

+286
-3267
lines changed

.cmake-format.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,83 @@ parse:
4141
pargs: 1
4242
kwargs:
4343
CYCLIC_DEPENDING_INCLUDES: '+'
44+
cpmaddpackage:
45+
pargs:
46+
nargs: '*'
47+
flags: []
48+
spelling: CPMAddPackage
49+
kwargs: &cpmaddpackagekwargs
50+
NAME: 1
51+
FORCE: 1
52+
VERSION: 1
53+
GIT_TAG: 1
54+
DOWNLOAD_ONLY: 1
55+
GITHUB_REPOSITORY: 1
56+
GITLAB_REPOSITORY: 1
57+
GIT_REPOSITORY: 1
58+
SVN_REPOSITORY: 1
59+
SVN_REVISION: 1
60+
SOURCE_DIR: 1
61+
DOWNLOAD_COMMAND: 1
62+
FIND_PACKAGE_ARGUMENTS: 1
63+
NO_CACHE: 1
64+
GIT_SHALLOW: 1
65+
URL: 1
66+
URL_HASH: 1
67+
URL_MD5: 1
68+
DOWNLOAD_NAME: 1
69+
DOWNLOAD_NO_EXTRACT: 1
70+
HTTP_USERNAME: 1
71+
HTTP_PASSWORD: 1
72+
EXCLUDE_FROM_ALL: 1
73+
SYSTEM: 1
74+
SOURCE_SUBDIR: 1
75+
QUIET: 1
76+
PATCHES: +
77+
OPTIONS: +
78+
cpmfindpackage:
79+
pargs:
80+
nargs: '*'
81+
flags: []
82+
spelling: CPMFindPackage
83+
kwargs: *cpmaddpackagekwargs
84+
cpmdeclarepackage:
85+
pargs:
86+
nargs: '*'
87+
flags: []
88+
spelling: CPMDeclarePackage
89+
kwargs: *cpmaddpackagekwargs
90+
packageproject:
91+
pargs:
92+
nargs: '*'
93+
flags: []
94+
spelling: packageProject
95+
kwargs:
96+
NAME: 1
97+
VERSION: 1
98+
NAMESPACE: 1
99+
INCLUDE_DIR: 1
100+
INCLUDE_DESTINATION: 1
101+
INCLUDE_HEADER_PATTERN: 1
102+
BINARY_DIR: 1
103+
COMPATIBILITY: 1
104+
VERSION_HEADER: 1
105+
EXPORT_HEADER: 1
106+
DISABLE_VERSION_SUFFIX: 1
107+
CPACK: 1
108+
DEPENDENCIES: +
109+
cpmgetpackage:
110+
pargs: 1
111+
spelling: CPMGetPackage
112+
cpmusepackagelock:
113+
pargs: 1
114+
spelling: CPMUsePackageLock
115+
cpmregisterpackage:
116+
pargs: 1
117+
spelling: CPMRegisterPackage
118+
cpmgetpackageversion:
119+
pargs: 2
120+
spelling: CPMGetPackageVersion
44121
_help_override_spec:
45122
- Override configurations per-command where available
46123
override_spec: {}

.github/workflows/ci_coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
run: |
6262
mkdir build && cd build
6363
cmake ../test/coverage -DCMAKE_BUILD_TYPE=Coverage
64-
make gtest_build yaml-cpp
64+
make gtest_main yaml-cpp
6565
6666
- name: Build tests
6767
working-directory: build

.github/workflows/ci_cpm.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2+
# SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
name: Update CPM
6+
7+
on:
8+
schedule:
9+
- cron: "0 12 * * SAT"
10+
workflow_dispatch:
11+
12+
env:
13+
TZ: Europe/Berlin
14+
15+
concurrency:
16+
group: update-cpm-actions
17+
cancel-in-progress: true
18+
19+
jobs:
20+
update_cpm:
21+
name: Update CPM
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 15
24+
if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch'
25+
steps:
26+
- name: Run update CPM
27+
uses: seqan/actions/update_cpm_package_lock@main
28+
with:
29+
token: ${{ secrets.SEQAN_ACTIONS_PAT }}
30+
gpg_key: ${{ secrets.SEQAN_ACTIONS_GPG_KEY }}
31+
gpg_passphrase: ${{ secrets.SEQAN_ACTIONS_GPG_PASSPHRASE }}
32+
package_lock_file: cmake/package-lock.cmake

.github/workflows/ci_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
mkdir build && cd build
6464
cmake ../test/unit -DCMAKE_BUILD_TYPE=Release \
6565
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
66-
make gtest_build yaml-cpp
66+
make gtest_main yaml-cpp
6767
6868
- name: Build tests
6969
working-directory: build

.github/workflows/ci_misc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
mkdir build && cd build
6363
cmake ../test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=Release \
6464
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
65-
make gtest_build yaml-cpp
65+
make gtest_main yaml-cpp
6666
6767
- name: Build tests
6868
working-directory: build

cmake/CPM.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-License-Identifier: MIT
2+
#
3+
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
4+
5+
set (CPM_DOWNLOAD_VERSION 0.40.2)
6+
set (CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")
7+
8+
if (CPM_SOURCE_CACHE)
9+
set (CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
10+
elseif (DEFINED ENV{CPM_SOURCE_CACHE})
11+
set (CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
12+
else ()
13+
set (CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
14+
endif ()
15+
16+
# Expand relative path. This is important if the provided path contains a tilde (~)
17+
get_filename_component (CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
18+
19+
file (DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
20+
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM})
21+
22+
include (${CPM_DOWNLOAD_LOCATION})

cmake/cpack_install.cmake.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2006-2024, Knut Reinert & Freie Universität Berlin
2+
# SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
5+
# Only if creating the source package (`make package_source`):
6+
# Copy dependency include directories into package's staging folder
7+
if (CPACK_SOURCE_INSTALLED_DIRECTORIES)
8+
configure_file ("@CPM_DOWNLOAD_LOCATION@" "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake" COPYONLY)
9+
if ("@use_ccache_ADDED@" STREQUAL "YES")
10+
configure_file ("@use_ccache_SOURCE_DIR@/ccache/CMakeLists.txt"
11+
"${CMAKE_CURRENT_BINARY_DIR}/test/cmake/sharg_require_ccache.cmake" COPYONLY)
12+
endif ()
13+
endif ()

cmake/package-lock.cmake

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# SPDX-FileCopyrightText: 2006-2024, Knut Reinert & Freie Universität Berlin
2+
# SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
# CPM Package Lock
6+
# This file should be committed to version control
7+
8+
# URL/GIT_TAG may be annotated with a branch name
9+
# This is needed for https://github.com/seqan/actions/tree/main/update_cpm_package_lock
10+
11+
# The first argument of CPMDeclarePackage can be freely chosen and is used as argument in CPMGetPackage.
12+
# The NAME argument should be package name that would also be used in a find_package call.
13+
# Ideally, both are the same, which might not always be possible: https://github.com/cpm-cmake/CPM.cmake/issues/603
14+
# This is needed to support CPM_USE_LOCAL_PACKAGES
15+
16+
# TDL
17+
set (SHARG_TDL_VERSION 1.0.1)
18+
CPMDeclarePackage (tdl
19+
NAME tdl
20+
VERSION ${SHARG_TDL_VERSION}
21+
GITHUB_REPOSITORY deNBI-cibi/tool_description_lib
22+
SYSTEM TRUE
23+
OPTIONS "INSTALL_TDL OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING")
24+
# googletest
25+
set (SHARG_GOOGLETEST_VERSION 1.15.2)
26+
CPMDeclarePackage (googletest
27+
NAME GTest
28+
VERSION ${SHARG_GOOGLETEST_VERSION}
29+
GITHUB_REPOSITORY google/googletest
30+
SYSTEM TRUE
31+
OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF" "CMAKE_MESSAGE_LOG_LEVEL WARNING")
32+
# doxygen-awesome
33+
set (SHARG_DOXYGEN_AWESOME_VERSION 2.3.4)
34+
CPMDeclarePackage (doxygen_awesome
35+
NAME doxygen_awesome
36+
VERSION ${SHARG_DOXYGEN_AWESOME_VERSION}
37+
GITHUB_REPOSITORY jothepro/doxygen-awesome-css
38+
DOWNLOAD_ONLY TRUE
39+
QUIET YES)
40+
# use_ccache
41+
set (SHARG_USE_CCACHE_VERSION d2a54ef555b6fc2d496a4c9506dbeb7cf899ce37)
42+
CPMDeclarePackage (use_ccache
43+
NAME use_ccache
44+
GIT_TAG ${SHARG_USE_CCACHE_VERSION} # main
45+
GITHUB_REPOSITORY seqan/cmake-scripts
46+
SOURCE_SUBDIR ccache
47+
SYSTEM TRUE
48+
EXCLUDE_FROM_ALL TRUE)

cmake/sharg-config.cmake

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,35 @@ macro (sharg_config_error text)
108108
endif ()
109109
endmacro ()
110110

111+
# ----------------------------------------------------------------------------
112+
# CPM
113+
# ----------------------------------------------------------------------------
114+
115+
# This will be true for git clones and source packages, but not for installed packages.
116+
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/CPM.cmake")
117+
set (SHARG_HAS_CPM TRUE)
118+
else ()
119+
set (SHARG_HAS_CPM FALSE)
120+
endif ()
121+
122+
if (SHARG_HAS_CPM)
123+
set (CPM_INDENT " CMake Package Manager CPM: ")
124+
include ("${CMAKE_CURRENT_LIST_DIR}/CPM.cmake")
125+
CPMUsePackageLock ("${CMAKE_CURRENT_LIST_DIR}/package-lock.cmake")
126+
endif ()
127+
111128
# ----------------------------------------------------------------------------
112129
# Find SHARG include path
113130
# ----------------------------------------------------------------------------
114131

115132
# Note that sharg-config.cmake can be standalone and thus SHARG_CLONE_DIR might be empty.
116-
# * `SHARG_CLONE_DIR` was already found in sharg-config-version.cmake
117133
# * `SHARG_INCLUDE_DIR` was already found in sharg-config-version.cmake
118-
find_path (SHARG_SUBMODULES_DIR
119-
NAMES submodules/tool_description_lib
120-
HINTS "${SHARG_CLONE_DIR}" "${SHARG_INCLUDE_DIR}/sharg")
121-
122134
if (SHARG_INCLUDE_DIR)
123135
sharg_config_print ("SHARG include dir found: ${SHARG_INCLUDE_DIR}")
124136
else ()
125137
sharg_config_error ("SHARG include directory could not be found (SHARG_INCLUDE_DIR: '${SHARG_INCLUDE_DIR}')")
126138
endif ()
127139

128-
# ----------------------------------------------------------------------------
129-
# Detect if we are a clone of repository and if yes auto-add submodules
130-
# ----------------------------------------------------------------------------
131-
132-
if (SHARG_CLONE_DIR)
133-
sharg_config_print ("Detected as running from a repository checkout…")
134-
endif ()
135-
136140
# ----------------------------------------------------------------------------
137141
# Options for CheckCXXSourceCompiles
138142
# ----------------------------------------------------------------------------
@@ -206,22 +210,13 @@ endif ()
206210
set (SHARG_USE_TDL FALSE)
207211

208212
if (NOT SHARG_NO_TDL)
209-
find_package (TDL QUIET HINTS ${SHARG_HINT_TDL})
210-
211-
if (NOT TDL_FOUND)
212-
if (EXISTS ${SHARG_SUBMODULES_DIR}/submodules/tool_description_lib)
213-
include (FetchContent)
214-
FetchContent_Declare (tdl SOURCE_DIR ${SHARG_SUBMODULES_DIR}/submodules/tool_description_lib)
215-
set (SHARG_LOG_LEVEL ${CMAKE_MESSAGE_LOG_LEVEL})
216-
set (CMAKE_MESSAGE_LOG_LEVEL "ERROR")
217-
option (INSTALL_TDL "Enable installation of TDL." ${INSTALL_SHARG})
218-
FetchContent_MakeAvailable (tdl)
219-
set (CMAKE_MESSAGE_LOG_LEVEL ${SHARG_LOG_LEVEL})
220-
set (TDL_FOUND TRUE)
221-
endif ()
213+
if (NOT SHARG_HAS_CPM)
214+
find_package (tdl QUIET)
215+
else ()
216+
CPMGetPackage (tdl)
222217
endif ()
223218

224-
if (TDL_FOUND)
219+
if (TDL_FOUND OR tdl_ADDED)
225220
sharg_config_print ("Optional dependency: TDL found.")
226221
set (SHARG_USE_TDL TRUE)
227222
list (APPEND SHARG_LIBRARIES tdl::tdl)
@@ -323,12 +318,6 @@ if (SHARG_FOUND AND NOT TARGET sharg::sharg)
323318
target_link_libraries (sharg_sharg INTERFACE ${SHARG_LIBRARIES})
324319
target_include_directories (sharg_sharg INTERFACE "${SHARG_INCLUDE_DIR}")
325320
add_library (sharg::sharg ALIAS sharg_sharg)
326-
327-
if (SHARG_USE_TDL)
328-
# Include TDL as system header to suppress warnings.
329-
get_target_property (tdl_include_dir tdl::tdl INTERFACE_INCLUDE_DIRECTORIES)
330-
target_include_directories (sharg_sharg SYSTEM INTERFACE ${tdl_include_dir})
331-
endif ()
332321
endif ()
333322

334323
set (CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})

cmake/sharg-install.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ install (FILES "${SHARG_CLONE_DIR}/CHANGELOG.md" #
1717
TYPE DOC)
1818

1919
# install cmake files in /share/cmake
20-
install (FILES "${SHARG_CLONE_DIR}/cmake/sharg-config.cmake"
21-
"${SHARG_CLONE_DIR}/cmake/sharg-config-version.cmake"
20+
install (FILES "${SHARG_CLONE_DIR}/cmake/sharg-config.cmake" "${SHARG_CLONE_DIR}/cmake/sharg-config-version.cmake"
2221
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/sharg")
2322

2423
# install sharg header files in /include/sharg

0 commit comments

Comments
 (0)