Skip to content

Commit da9077d

Browse files
authored
Merge pull request #202 from eseiler/fix/install
[INFRA] Add external_project tests
2 parents 6948cf4 + 01d64e2 commit da9077d

File tree

14 files changed

+408
-12
lines changed

14 files changed

+408
-12
lines changed

.github/workflows/ci_cmake.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CMake
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
types:
9+
- unlabeled
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: cmake-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: ${{ github.event_name != 'push' }}
15+
16+
env:
17+
SHARG_NO_VERSION_CHECK: 1
18+
TZ: Europe/Berlin
19+
20+
defaults:
21+
run:
22+
shell: bash -Eexuo pipefail {0}
23+
24+
jobs:
25+
build:
26+
name: "External project"
27+
runs-on: ubuntu-22.04
28+
timeout-minutes: 120
29+
if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'lint'
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
with:
34+
path: sharg-parser
35+
fetch-depth: 1
36+
submodules: true
37+
38+
- name: Install CMake
39+
uses: seqan/actions/setup-cmake@main
40+
with:
41+
cmake: 3.16.9
42+
43+
- name: Setup toolchain
44+
uses: seqan/actions/setup-toolchain@main
45+
with:
46+
compiler: gcc-13
47+
use_actions_cache: false
48+
49+
- name: Configure tests
50+
run: |
51+
mkdir sharg-build
52+
cd sharg-build
53+
cmake ../sharg-parser/test/external_project -DCMAKE_BUILD_TYPE=Debug
54+
make -j2 sharg_test_prerequisite
55+
56+
- name: Build tests
57+
run: |
58+
cd sharg-build
59+
make -k -j2
60+

.github/workflows/lint.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,23 @@ jobs:
5555
cancel-in-progress: true
5656
runs-on: ubuntu-22.04
5757
steps:
58-
- name: "Cancel Coverage"
59-
run: echo "Cancelling Coverage"
58+
- name: "Cancel Documentation"
59+
run: echo "Cancelling Documentation"
60+
cancel_cmake:
61+
name: Cancel running Workflows
62+
concurrency:
63+
group: cmake-${{ github.event.pull_request.number }}
64+
cancel-in-progress: true
65+
runs-on: ubuntu-22.04
66+
steps:
67+
- name: "Cancel CMake"
68+
run: echo "Cancelling CMake"
6069
lint:
6170
name: Lint
6271
concurrency:
6372
group: lint-${{ github.event.pull_request.number }}
6473
cancel-in-progress: true
65-
needs: [cancel_linux, cancel_macos, cancel_misc, cancel_coverage, cancel_documentation]
74+
needs: [cancel_linux, cancel_macos, cancel_misc, cancel_coverage, cancel_documentation, cancel_cmake]
6675
runs-on: ubuntu-22.04
6776
timeout-minutes: 15
6877
steps:

CHANGELOG.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,29 @@ The following API changes should be documented as such:
1818
If possible, provide tooling that performs the changes, e.g. a shell-script.
1919
-->
2020

21+
# Release 1.1.1
22+
23+
## Bug fixes
24+
25+
* Fixed installation of Sharg via `make install` ([#202](https://github.com/seqan/sharg-parser/pull/202)).
26+
27+
## API changes
28+
29+
#### Compiler
30+
31+
* Dropped support for gcc-10 ([#199](https://github.com/seqan/sharg-parser/pull/199)).
32+
* Added support for gcc-13 ([#199](https://github.com/seqan/sharg-parser/pull/199)).
33+
* Added support for clang-17 ([#197](https://github.com/seqan/sharg-parser/pull/197),
34+
[#198](https://github.com/seqan/sharg-parser/pull/198)).
35+
2136
# Release 1.1.0
2237

2338
## Features
2439

2540
* We support Gitpod. [Click here](https://gitpod.io/#https://github.com/seqan/sharg-parser/)
2641
to try it out.
2742
* **CWL support** (Common Workflow Language): An app using Sharg can now automatically export a CWL tool
28-
description file via `--export-help cwl` [#94](https://github.com/seqan/sharg-parser/pull/94).
29-
30-
## API changes
43+
description file via `--export-help cwl` ([#94](https://github.com/seqan/sharg-parser/pull/94)).
3144

3245
## Bug fixes
3346

build_system/sharg-config.cmake

-5
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,7 @@ endif ()
217217
# ----------------------------------------------------------------------------
218218
# tool description lib (tdl) dependency
219219
# ----------------------------------------------------------------------------
220-
221-
set (STORED_CMAKE_MESSAGE_LOG_LEVEL "${CMAKE_MESSAGE_LOG_LEVEL}")
222-
set (CMAKE_MESSAGE_LOG_LEVEL "ERROR")
223220
find_package (TDL QUIET HINTS ${SHARG_SUBMODULES_DIR}/submodules/tool_description_lib ${SHARG_HINT_TDL})
224-
set (CMAKE_MESSAGE_LOG_LEVEL "${STORED_CMAKE_MESSAGE_LOG_LEVEL}")
225-
unset (STORED_CMAKE_MESSAGE_LOG_LEVEL)
226221

227222
if (TDL_FOUND)
228223
sharg_config_print ("Dependency: TDL found.")

test/external_project/CMakeLists.txt

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# --------------------------------------------------------------------------------------------------------
2+
# Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
3+
# Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
4+
# This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5+
# shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/main/LICENSE.md
6+
# --------------------------------------------------------------------------------------------------------
7+
8+
cmake_minimum_required (VERSION 3.16)
9+
project (sharg_test_external_project CXX)
10+
11+
include (../sharg-test.cmake) # for SHARG_EXTERNAL_PROJECT_CMAKE_ARGS, SHARG_VERSION
12+
include (ExternalProject)
13+
14+
set (SHARG_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../")
15+
16+
include (install-sharg.cmake)
17+
18+
option (SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE
19+
"Enable this option if you want to get a detailed list which paths were considered for find_package(...)" FALSE)
20+
21+
# 1) This tests test/external_project/sharg_submodule_add_subdirectory/CMakeLists.txt
22+
# That means we use add_subdirectory directly on sharg's top level CMakeLists.txt.
23+
# This will automatically call find_package and expose our sharg::sharg target.
24+
# This is expected to work with CMake >= 3.4.
25+
# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../)
26+
ExternalProject_Add (
27+
sharg_submodule_add_subdirectory
28+
PREFIX sharg_submodule_add_subdirectory
29+
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_submodule_add_subdirectory"
30+
CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS}
31+
"-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}" #
32+
"-DSHARG_ROOT=${SHARG_ROOT}")
33+
34+
# 2) This tests test/external_project/sharg_submodule_find_package/CMakeLists.txt
35+
# We have a sharg checkout somewhere and we point CMAKE_PREFIX_PATH to <checkout>/sharg/build_system
36+
# and then use `find_package` to find `sharg-config.cmake` which exposes our `sharg::sharg` target.
37+
# This is expected to work with CMake >= 3.4.
38+
# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../)
39+
ExternalProject_Add (
40+
sharg_submodule_find_package
41+
PREFIX sharg_submodule_find_package
42+
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_submodule_find_package"
43+
CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} "-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}"
44+
"-DCMAKE_PREFIX_PATH=${SHARG_ROOT}/build_system")
45+
46+
# 3) This tests test/external_project/sharg_installed/CMakeLists.txt
47+
# This test assumes that sharg was installed by make install (e.g. system-wide).
48+
# This is the way most upstream packages, like debian, provide our library.
49+
# This test assumes that `sharg-config.cmake` can be found by cmake in some global paths like /usr/share/cmake/.
50+
#
51+
# We simulate this by using our `make package` release, e.g. the one we release under
52+
# https://github.com/seqan/sharg/releases, and unzipping it to some folder and making
53+
# that path globally accessible by CMAKE_SYSTEM_PREFIX_PATH.
54+
# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../)
55+
ExternalProject_Add (
56+
sharg_installed
57+
PREFIX sharg_installed
58+
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_installed"
59+
CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} "-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}"
60+
"-DCMAKE_SYSTEM_PREFIX_PATH=${SHARG_SYSTEM_PREFIX}")
61+
add_dependencies (sharg_installed sharg_test_prerequisite)
62+
63+
# 4) This tests test/external_project/sharg_fetch_content_zip/CMakeLists.txt
64+
# It uses fetch_content (a CMake 3.14 feature) to download our zip-release (e.g. zip, tar.xz) from
65+
# https://github.com/seqan/sharg/releases. fetch_content will automatically download, verify, extract it.
66+
# The user only needs to define CMAKE_PREFIX_PATH to be able to find our `sharg-config.cmake`.
67+
# Note that FetchContent is a CMake >= 3.14 feature.
68+
# This is expected to work with CMake >= 3.14.
69+
# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../)
70+
ExternalProject_Add (
71+
sharg_fetch_content_zip
72+
PREFIX sharg_fetch_content_zip
73+
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_fetch_content_zip"
74+
CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} "-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}"
75+
"-DSHARG_PACKAGE_ZIP_URL=${SHARG_PACKAGE_ZIP_URL}")
76+
add_dependencies (sharg_fetch_content_zip sharg_test_prerequisite)
77+
78+
# 5) This test is the same as 2) but emulates the settings within the setup tutorial.
79+
# This test is used as snippet in the setup tutorial.
80+
ExternalProject_Add (
81+
sharg_setup_tutorial
82+
PREFIX sharg_setup_tutorial
83+
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_setup_tutorial"
84+
CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} "-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# --------------------------------------------------------------------------------------------------------
2+
# Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
3+
# Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
4+
# This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5+
# shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/main/LICENSE.md
6+
# --------------------------------------------------------------------------------------------------------
7+
8+
# list all search places
9+
# NOTE: this can be enabled globally by -DSHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE=1 to help debug search paths
10+
# set (CMAKE_FIND_DEBUG_MODE ${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE})
11+
12+
macro (sharg_print_diagnostics text)
13+
message (STATUS " ${text}")
14+
endmacro ()
15+
16+
message (STATUS "=== SHARG find_package Diagnostics start ===")
17+
sharg_print_diagnostics ("CMAKE_COMMAND: ${CMAKE_COMMAND}")
18+
sharg_print_diagnostics ("CMAKE_VERSION: ${CMAKE_VERSION}")
19+
sharg_print_diagnostics ("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
20+
21+
sharg_print_diagnostics (
22+
"Search paths (https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure)")
23+
sharg_print_diagnostics ("1) CMAKE_FIND_USE_PACKAGE_ROOT_PATH: ${CMAKE_FIND_USE_CMAKE_PATH}")
24+
sharg_print_diagnostics (" SHARG_ROOT: ${SHARG_ROOT}")
25+
26+
sharg_print_diagnostics ("2) CMAKE_FIND_USE_CMAKE_PATH: ${CMAKE_FIND_USE_CMAKE_PATH}")
27+
sharg_print_diagnostics (" CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
28+
sharg_print_diagnostics (" CMAKE_FRAMEWORK_PATH: ${CMAKE_FRAMEWORK_PATH}")
29+
sharg_print_diagnostics (" CMAKE_APPBUNDLE_PATH: ${CMAKE_APPBUNDLE_PATH}")
30+
31+
sharg_print_diagnostics ("3) CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: ${CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH}")
32+
sharg_print_diagnostics (" SHARG_DIR: ${SHARG_DIR}")
33+
34+
# 4) Using the HINTS option.
35+
# See point 4 in https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure.
36+
# There is no output.
37+
38+
sharg_print_diagnostics ("5) CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: ${CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH}")
39+
40+
sharg_print_diagnostics ("6) CMAKE_FIND_USE_PACKAGE_REGISTRY: ${CMAKE_FIND_USE_PACKAGE_REGISTRY}")
41+
42+
sharg_print_diagnostics ("7) CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: ${CMAKE_FIND_USE_CMAKE_SYSTEM_PATH}")
43+
sharg_print_diagnostics (" CMAKE_SYSTEM_PREFIX_PATH: ${CMAKE_SYSTEM_PREFIX_PATH}")
44+
sharg_print_diagnostics (" CMAKE_SYSTEM_FRAMEWORK_PATH: ${CMAKE_SYSTEM_FRAMEWORK_PATH}")
45+
sharg_print_diagnostics (" CMAKE_SYSTEM_APPBUNDLE_PATH: ${CMAKE_SYSTEM_APPBUNDLE_PATH}")
46+
47+
sharg_print_diagnostics ("8) CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY: ${CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY}")
48+
message (STATUS "=== SHARG find_package Diagnostics end ===")
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# --------------------------------------------------------------------------------------------------------
2+
# Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
3+
# Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
4+
# This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5+
# shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/main/LICENSE.md
6+
# --------------------------------------------------------------------------------------------------------
7+
8+
cmake_minimum_required (VERSION 3.14)
9+
10+
# install and package sharg library
11+
ExternalProject_Add (
12+
sharg_test_prerequisite
13+
PREFIX sharg_test_prerequisite
14+
SOURCE_DIR "${SHARG_ROOT}"
15+
CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} #
16+
"-DCMAKE_INSTALL_PREFIX=<BINARY_DIR>/usr"
17+
STEP_TARGETS configure install
18+
BUILD_BYPRODUCTS "<BINARY_DIR>/include")
19+
20+
set (SHARG_PACKAGE_ZIP_URL "${PROJECT_BINARY_DIR}/sharg-${SHARG_VERSION}-${CMAKE_SYSTEM_NAME}.zip")
21+
ExternalProject_Add_Step (
22+
sharg_test_prerequisite package
23+
COMMAND ${CMAKE_CPACK_COMMAND} -G ZIP -B "${PROJECT_BINARY_DIR}"
24+
DEPENDEES configure install
25+
WORKING_DIRECTORY "<BINARY_DIR>"
26+
BYPRODUCTS ${SHARG_PACKAGE_ZIP_URL} #
27+
"${SHARG_PACKAGE_ZIP_URL}.sha256")
28+
29+
ExternalProject_Get_Property (sharg_test_prerequisite BINARY_DIR)
30+
set (SHARG_SYSTEM_PREFIX "${BINARY_DIR}/usr")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# --------------------------------------------------------------------------------------------------------
2+
# Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
3+
# Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
4+
# This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5+
# shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/main/LICENSE.md
6+
# --------------------------------------------------------------------------------------------------------
7+
8+
cmake_minimum_required (VERSION 3.14)
9+
project (sharg_app CXX)
10+
11+
# --- helper scripts
12+
include (../find-package-diagnostics.cmake)
13+
file (SHA256 "${SHARG_PACKAGE_ZIP_URL}" SHARG_PACKAGE_ZIP_HASH)
14+
message (STATUS "SHARG_PACKAGE_ZIP_URL: ${SHARG_PACKAGE_ZIP_URL}")
15+
message (STATUS "SHARG_PACKAGE_ZIP_HASH: SHA256=${SHARG_PACKAGE_ZIP_HASH}")
16+
# ---
17+
18+
# fetch sharg sources (requires >= cmake 3.14)
19+
include (FetchContent)
20+
FetchContent_Declare (
21+
sharg
22+
URL "${SHARG_PACKAGE_ZIP_URL}" # change these values
23+
URL_HASH "SHA256=${SHARG_PACKAGE_ZIP_HASH}" # change these values
24+
)
25+
FetchContent_MakeAvailable (sharg)
26+
27+
# add sharg to search path
28+
list (APPEND CMAKE_PREFIX_PATH "${sharg_SOURCE_DIR}")
29+
30+
# require sharg with a version between >=1.0.0 and <2.0.0
31+
find_package (sharg 1.0 REQUIRED)
32+
33+
# build app with sharg
34+
add_executable (hello_world ../src/hello_world.cpp)
35+
target_link_libraries (hello_world sharg::sharg)
36+
install (TARGETS hello_world)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# --------------------------------------------------------------------------------------------------------
2+
# Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
3+
# Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
4+
# This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5+
# shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/main/LICENSE.md
6+
# --------------------------------------------------------------------------------------------------------
7+
8+
cmake_minimum_required (VERSION 3.4)
9+
project (sharg_app CXX)
10+
11+
# --- helper scripts
12+
include (../find-package-diagnostics.cmake)
13+
# ---
14+
15+
# require sharg with a version between >=1.0.0 and <2.0.0
16+
find_package (sharg 1.0 REQUIRED)
17+
18+
# build app with sharg
19+
add_executable (hello_world ../src/hello_world.cpp)
20+
target_link_libraries (hello_world sharg::sharg)
21+
if (CMAKE_VERSION VERSION_LESS 3.14)
22+
install (TARGETS hello_world RUNTIME DESTINATION bin)
23+
else ()
24+
install (TARGETS hello_world) # RUNTIME DESTINATION not needed anymore since cmake 3.14
25+
endif ()

0 commit comments

Comments
 (0)