Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LoadStaticSharedTargets
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CMake
LoadStaticSharedTargets
Commits
b5554004
Unverified
Commit
b5554004
authored
2 months ago
by
Tim Kaune
Browse files
Options
Downloads
Patches
Plain Diff
Add test and workflow presets
Cleanup hard-coded test configuration Bump CMake package version number
parent
8a2f427c
Branches
Branches containing commit
Tags
v1.7.0
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.github/workflows/build-and-test.yml
+3
-9
3 additions, 9 deletions
.github/workflows/build-and-test.yml
CMakeLists.txt
+2
-8
2 additions, 8 deletions
CMakeLists.txt
CMakePresets.json
+122
-0
122 additions, 0 deletions
CMakePresets.json
README.md
+38
-23
38 additions, 23 deletions
README.md
with
165 additions
and
40 deletions
.github/workflows/build-and-test.yml
+
3
−
9
View file @
b5554004
...
...
@@ -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
This diff is collapsed.
Click to expand it.
CMakeLists.txt
+
2
−
8
View file @
b5554004
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
CMakePresets.json
+
122
−
0
View file @
b5554004
...
...
@@ -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"
}
]
}
]
}
This diff is collapsed.
Click to expand it.
README.md
+
38
−
23
View file @
b5554004
...
...
@@ -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
-v
b
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(
)
```
Th
is
adds the LoadStaticSharedTargets module to the
`CMAKE_MODULE_PATH`
variable
which enables the include by name only.
Th
e
`find_package()`
command
adds the LoadStaticSharedTargets module to the
`CMAKE_MODULE_PATH`
variable
which enables the
`
include
()`
by name only.
## Further Reading ##
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment