-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CMake commands to install byteme for find_package. (#3)
Also added an action to check that the installation can be used.
- Loading branch information
Showing
4 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
name: Check CMake install | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get latest CMake | ||
uses: lukka/get-cmake@latest | ||
|
||
- name: Configure the build | ||
run: cmake -S . -B build | ||
|
||
- name: Install the library | ||
run: sudo cmake --install build | ||
|
||
- name: Test downstream usage | ||
run: | | ||
mkdir _downstream | ||
touch _downstream/source.cpp | ||
cat << EOF > _downstream/CMakeLists.txt | ||
cmake_minimum_required(VERSION 3.24) | ||
project(test_install) | ||
add_executable(whee source.cpp) | ||
find_package(ltla_byteme) | ||
target_link_libraries(whee ltla::byteme) | ||
EOF | ||
cd _downstream && cmake -S . -B build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,49 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
cmake_minimum_required(VERSION 3.24) | ||
|
||
project(byteme | ||
VERSION 1.0.0 | ||
VERSION 1.0.1 | ||
DESCRIPTION "No-frills byte streaming from file" | ||
LANGUAGES CXX) | ||
|
||
add_library(byteme INTERFACE) | ||
add_library(ltla::byteme ALIAS byteme) | ||
|
||
target_include_directories(byteme INTERFACE include/) | ||
include(GNUInstallDirs) | ||
target_include_directories(byteme INTERFACE | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" | ||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/byteme>") | ||
|
||
# Building the test-related machinery, if we are compiling this library directly. | ||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) | ||
option(BYTEME_TESTS "Build byteme's test suite." ON) | ||
else() | ||
option(BYTEME_TESTS "Build byteme's test suite." OFF) | ||
endif() | ||
|
||
if(BYTEME_TESTS) | ||
include(CTest) | ||
if(BUILD_TESTING) | ||
add_subdirectory(tests) | ||
endif() | ||
endif() | ||
|
||
# Installing for find_package. | ||
include(CMakePackageConfigHelpers) | ||
|
||
install(DIRECTORY include/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/byteme) | ||
|
||
install(TARGETS byteme | ||
EXPORT bytemeTargets) | ||
|
||
install(EXPORT bytemeTargets | ||
FILE ltla_bytemeTargets.cmake | ||
NAMESPACE ltla:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ltla_byteme) | ||
|
||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/ltla_bytemeConfig.cmake" | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ltla_byteme) | ||
|
||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ltla_bytemeConfig.cmake" | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ltla_byteme) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/ltla_bytemeTargets.cmake") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters