Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cross-platform CMake/C++ library to get the installation prefix of shared library in a relocatable way.

License

NotificationsYou must be signed in to change notification settings

ami-iit/reloc-cpp

Repository files navigation

CMake/C++ library to get the installation prefix of a shared library in a relocatable way.

In a nutshell, it permits to avoid the need to hardcode the location ofCMAKE_INSTALL_PREFIX in a shared library if you need it to localize other resources installed with the package. This permits to easily move the installation prefix in a location different fromCMAKE_INSTALL_PREFIX after the installation (i.e. making it arelocatable installation), as long as the library is compiled as shared. This is useful when the C++ shared library is packaged in package managers that create the package with a givenCMAKE_INSTALL_PREFIX and install it with a different prefix, such asconda,vcpkg orconan.

In the case that the library is compiled as static,reloc-cpp will fall back to hardcodeCMAKE_INSTALL_PREFIX in the library.

reloc-cpp requires the use of C++ 17 or any later version.

Installation

FetchContent

include(FetchContent)FetchContent_Declare(  reloc-cpp  GIT_REPOSITORY https://github.com/ami-iit/reloc-cpp.git  GIT_TAG        v0.1.0)FetchContent_MakeAvailable(reloc-cpp)

Usage

In your CMake build system you can usereloc-cpp as:

add_library(yourLibrary)# ...reloc_cpp_generate(yourLibrary                   GENERATED_HEADER${CMAKE_CURRENT_BINARY_DIR}/yourLibrary_getInstallPrefix.h                   GENERATED_FUNCTION yourLibrary::getInstallPrefix)

then, you can use it in C++ as:

#include<yourLibrary_getInstallationPrefix.h>// This return the value corresponding to CMAKE_INSTALL_PREFIXstd::string installPrefix = yourLibrary::getInstallPrefix().value();

Contributing

Pull requests are welcome. For major changes, please open an issue firstto discuss what you would like to change.

References

References that were useful as inspiration when developing reloc-cpp:

Resources that could be useful as an alternative to reloc-cpp:

License

BSD-3-Clause

About

Cross-platform CMake/C++ library to get the installation prefix of shared library in a relocatable way.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp