-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RUNTIME_DESTINATION variable (#45)
* Add RUNTIME_DESTINATION It's possible to put libraries and binaries directly to bin/ and lib/ (using RUNTIME_DESTINATION /) instead of bin/<name-version> and lib/<name-version> * Add tests for RUNTIME_DESTINATION feature * Update README.md * Update .cmake-format * Update .github/workflows/test.yml Refactor: move test to it's own step Co-authored-by: Lars Melchior <[email protected]> * Fix: syntax error in test.yml --------- Co-authored-by: Lars Melchior <[email protected]>
- Loading branch information
1 parent
5f51898
commit 738d2ed
Showing
9 changed files
with
79 additions
and
8 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 |
---|---|---|
|
@@ -58,4 +58,5 @@ parse: | |
EXPORT_HEADER: 1 | ||
DISABLE_VERSION_SUFFIX: 1 | ||
CPACK: 1 | ||
RUNTIME_DESTINATION: 1 | ||
DEPENDENCIES: + |
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ jobs: | |
uses: jwlawson/[email protected] | ||
with: | ||
cmake-version: 3.18.4 | ||
|
||
- name: test and install local build | ||
run: | | ||
cmake -S test -B build/local | ||
|
@@ -58,7 +58,7 @@ jobs: | |
uses: jwlawson/[email protected] | ||
with: | ||
cmake-version: 3.18.4 | ||
|
||
- name: build for packaging | ||
run: | | ||
cmake -S test -B build/local -DTEST_CPACK=YES | ||
|
@@ -68,6 +68,9 @@ jobs: | |
cpack -G DEB . | ||
dpkg -I *deb | grep "Maintainer: Foo Bar <[email protected]>" | ||
sudo -E dpkg -i *.deb | ||
- name: check if we can explicitly set the runtime destination | ||
run: test -e /usr/lib/libruntime_destination_dependency.a | ||
|
||
- name: test installed build | ||
run: | | ||
|
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
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
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ if(TEST_INSTALLED_VERSION) | |
find_package(header_only 1.0 REQUIRED) | ||
find_package(namespaced_dependency 4.5.6 REQUIRED) | ||
find_package(transitive_dependency 7.8.9 REQUIRED) | ||
find_package(runtime_destination_dependency 1.5 REQUIRED) | ||
else() | ||
if(TEST_CPACK) | ||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Foo Bar <[email protected]>") | ||
|
@@ -21,13 +22,14 @@ else() | |
add_subdirectory(header_only) | ||
add_subdirectory(namespaced_dependency) | ||
add_subdirectory(transitive_dependency) | ||
add_subdirectory(runtime_destination_dependency) | ||
endif() | ||
|
||
add_executable(main main.cpp) | ||
|
||
target_link_libraries( | ||
main dependency header_only ns::namespaced_dependency | ||
transitive_dependency::transitive_dependency | ||
transitive_dependency::transitive_dependency runtime_destination_dependency | ||
) | ||
|
||
enable_testing() | ||
|
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
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,30 @@ | ||
cmake_minimum_required(VERSION 3.14...3.22) | ||
|
||
project( | ||
runtime_destination_dependency | ||
VERSION 1.5 | ||
LANGUAGES CXX | ||
DESCRIPTION "A dependency for testing RUNTIME_DESTINATION in PackageProject.cmake" | ||
) | ||
|
||
add_library(runtime_destination_dependency STATIC source/dependency.cpp) | ||
|
||
target_include_directories( | ||
runtime_destination_dependency | ||
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}> | ||
) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../.. PackageProject) | ||
|
||
packageProject( | ||
NAME ${PROJECT_NAME} | ||
VERSION ${PROJECT_VERSION} | ||
BINARY_DIR ${PROJECT_BINARY_DIR} | ||
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include | ||
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION} | ||
VERSION_HEADER "runtime_destination_dependency/version.h" | ||
RUNTIME_DESTINATION / # this is relative path to <...>/lib | ||
DEPENDENCIES "" | ||
CPACK YES | ||
) |
3 changes: 3 additions & 0 deletions
3
test/runtime_destination_dependency/include/runtime_destination_dependency/dependency.h
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 @@ | ||
#pragma once | ||
|
||
void runtimeDestinationDependency(); |
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,15 @@ | ||
#include <runtime_destination_dependency/version.h> | ||
|
||
#include <iostream> | ||
|
||
void runtimeDestinationDependency() { | ||
std::cout << "Using dependency version " << RUNTIME_DESTINATION_DEPENDENCY_VERSION << std::endl; | ||
std::cout << "Dependency version major: " << RUNTIME_DESTINATION_DEPENDENCY_VERSION_MAJOR | ||
<< std::endl; | ||
std::cout << "Dependency version minor: " << RUNTIME_DESTINATION_DEPENDENCY_VERSION_MINOR | ||
<< std::endl; | ||
std::cout << "Dependency version patch: " << RUNTIME_DESTINATION_DEPENDENCY_VERSION_PATCH | ||
<< std::endl; | ||
std::cout << "Dependency version build: " << RUNTIME_DESTINATION_DEPENDENCY_VERSION_TWEAK | ||
<< std::endl; | ||
} |