Skip to content
Snippets Groups Projects
Unverified Commit b5554004 authored by Tim Kaune's avatar Tim Kaune
Browse files

Add test and workflow presets

Cleanup hard-coded test configuration
Bump CMake package version number
parent 8a2f427c
Branches
Tags v1.7.0
No related merge requests found
......@@ -7,18 +7,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: prepare
run: sudo apt-get install -y ninja-build
run: sudo apt-get install -y git cmake ninja-build
- name: info
run: |
git version
cmake --version
ninja --version
- uses: actions/checkout@v4
- name: configure
run: cmake --preset ninja
- name: build
run: cmake --build --preset ninja --verbose
- name: install
run: cmake --build --preset ninja --verbose --target install
- name: test
run: cmake --build --preset ninja --verbose --target check
- name: build-and-test
run: cmake --workflow --preset ci-ninja
......@@ -25,11 +25,11 @@ SOFTWARE.
cmake_minimum_required(VERSION 3.25)
set(CMAKE_MAXIMUM_SUPPORTED_VERSION 3.29)
set(CMAKE_MAXIMUM_SUPPORTED_VERSION 3.31)
include("./cmake/HandlePolicies.cmake" NO_POLICY_SCOPE)
project(LoadStaticSharedTargets VERSION 1.6.0 LANGUAGES NONE)
project(LoadStaticSharedTargets VERSION 1.7.0 LANGUAGES NONE)
include(GNUInstallDirs)
......@@ -37,10 +37,6 @@ string(COMPARE EQUAL "${CMAKE_PROJECT_NAME}" "${PROJECT_NAME}" IS_TOP_LEVEL)
if (IS_TOP_LEVEL)
include(CTest)
if (NOT DEFINED CMAKE_CTEST_ARGUMENTS)
set(CMAKE_CTEST_ARGUMENTS "--verbose")
endif ()
endif ()
option(LoadStaticSharedTargets_INCLUDE_PACKAGING "Include packaging rules for LoadStaticSharedTargets" "${IS_TOP_LEVEL}")
......@@ -48,8 +44,6 @@ option(LoadStaticSharedTargets_INCLUDE_PACKAGING "Include packaging rules for Lo
add_subdirectory(src)
if (IS_TOP_LEVEL AND BUILD_TESTING)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V)
add_subdirectory(tests EXCLUDE_FROM_ALL)
endif ()
......
......@@ -35,15 +35,137 @@
}
],
"buildPresets": [
{
"name": "verbose",
"hidden": true,
"verbose": true
},
{
"name": "ninja",
"inherits": [
"verbose"
],
"displayName": "Default Build using Ninja",
"configurePreset": "ninja"
},
{
"name": "ninja-install",
"inherits": [
"ninja"
],
"displayName": "Default Build and Installation using Ninja",
"targets": [
"install"
]
},
{
"name": "make",
"inherits": [
"verbose"
],
"displayName": "Default Build using Make",
"configurePreset": "make"
},
{
"name": "make-install",
"inherits": [
"make"
],
"displayName": "Default Build and Installation using Make",
"targets": [
"install"
]
}
],
"testPresets": [
{
"name": "verbose",
"hidden": true,
"output": {
"verbosity": "verbose"
}
},
{
"name": "ninja",
"inherits": [
"verbose"
],
"displayName": "Default Test using Ninja",
"configurePreset": "ninja"
},
{
"name": "make",
"inherits": [
"verbose"
],
"displayName": "Default Test using Make",
"configurePreset": "make"
}
],
"workflowPresets": [
{
"name": "dev-ninja",
"displayName": "Developer Workflow using Ninja",
"steps": [
{
"type": "configure",
"name": "ninja"
},
{
"type": "build",
"name": "ninja-install"
}
]
},
{
"name": "ci-ninja",
"displayName": "CI Workflow using Ninja",
"steps": [
{
"type": "configure",
"name": "ninja"
},
{
"type": "build",
"name": "ninja"
},
{
"type": "test",
"name": "ninja"
}
]
},
{
"name": "dev-make",
"displayName": "Developer Workflow using Make",
"steps": [
{
"type": "configure",
"name": "make"
},
{
"type": "build",
"name": "make-install"
}
]
},
{
"name": "ci-make",
"displayName": "CI Workflow using Make",
"steps": [
{
"type": "configure",
"name": "make"
},
{
"type": "build",
"name": "make"
},
{
"type": "test",
"name": "make"
}
]
}
]
}
......@@ -26,9 +26,9 @@ SOFTWARE.
# LoadStaticSharedTargets #
This CMake module contains a macro for loading static or shared exported library
targets in a CMake package config file. Static or shared targets can be
explicitly (via `COMPONENTS`) or implicitly (via `BUILD_SHARED_LIBS`) imported
with the `find_package()` command.
targets in a CMake package config file. Static or shared targets can be imported
explicitly (via `COMPONENTS`) or implicitly (via `BUILD_SHARED_LIBS`) with the
`find_package()` command.
## Prerequisites ##
......@@ -63,7 +63,7 @@ $ brew install cmake ninja
#### MacPorts ####
```shell
$ sudo port -vb install cmake-devel ninja
$ sudo port -v install cmake ninja
```
### Windows ###
......@@ -87,27 +87,42 @@ process.
1. Clone the git repository or download the source code archive and unpack it to
an arbitrary directory (e.g. `load-static-shared-targets`).
2. Go to this directory and type `cmake --list-presets`. A list of available
build configurations will be shown to you.
3. For configuring the project, type `cmake --preset ninja`. This will populate
the `./build` directory with a CMake configuration tree. By default, the
configured installation directory is `./install`. You can specify a different
install location by setting the `CMAKE_INSTALL_PREFIX` variable:
2. Go to this directory and type `cmake --workflow --list-presets`. A list of
available build workflows will be shown to you.
3. For configuring, building and installing the project, type `cmake --workflow
--preset dev-ninja`. This will populate the `./build` directory with a CMake
configuration tree, execute the build and install the project. By default,
the configured installation directory is `./install`.
4. For running the tests, type `cmake --workflow --preset ci-ninja`.
### How to customize the build from the command line ###
1. You can specify a different install location by using the configure preset
directly while setting the `CMAKE_INSTALL_PREFIX` variable:
```shell
$ cmake --preset ninja -D "CMAKE_INSTALL_PREFIX=/path/to/install/prefix"
```
4. Now, you can build with `cmake --build --preset ninja`. You should see some
informative terminal output.
5. Finally, install the built artifacts to the configured install prefix with
`cmake --build --preset ninja --target install`. If the configured install
prefix is a system-wide location (like `/usr/local`), installing might
require `sudo`.
If the configured install prefix is a system-wide location (like
`/usr/local`), installing might require `sudo`.
2. Now, you can build manually with `cmake --build --preset ninja-install`. You
should see some informative terminal output.
### How to customize the build using user presets ###
Create the file `./CMakeUserPresets.json` and build your own configure, build,
test or workflow presets by inheriting from the project's default presets.
Please refer to the [CMake Documentation about presets][1] for details.
[1]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
## How to use ##
Now, the `LoadStaticSharedTargets` module is installed and you can use it in
other projects. The installed `LoadStaticSharedTargets` package is discoverable
by CMake as __LoadStaticSharedTargets__. In the `CMakeLists.txt` of the other
With the `LoadStaticSharedTargets` module installed, you can use it in other
projects. The installed `LoadStaticSharedTargets` package is discoverable by
CMake as __LoadStaticSharedTargets__. In the `CMakeLists.txt` of the other
project, do the following:
```cmake
......@@ -116,9 +131,9 @@ include(FetchContent)
FetchContent_Declare(
LoadStaticSharedTargets
GIT_REPOSITORY "https://github.com/lepus2589/LoadStaticSharedTargets.git"
GIT_TAG v1.5.2
GIT_TAG v1.7.0
SYSTEM
FIND_PACKAGE_ARGS 1.5.2 CONFIG NAMES LoadStaticSharedTargets
FIND_PACKAGE_ARGS 1.7.0 CONFIG NAMES LoadStaticSharedTargets
)
set(LoadStaticSharedTargets_INCLUDE_PACKAGING TRUE)
FetchContent_MakeAvailable(LoadStaticSharedTargets)
......@@ -151,8 +166,8 @@ load_static_shared_targets(
)
```
This adds the LoadStaticSharedTargets module to the `CMAKE_MODULE_PATH` variable
which enables the include by name only.
The `find_package()` command adds the LoadStaticSharedTargets module to the
`CMAKE_MODULE_PATH` variable which enables the `include()` by name only.
## Further Reading ##
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment