From a5dfbe8b4f58a3f5f9d2e3b7eacb38b6cd9e037d Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Fri, 30 Jun 2023 18:04:00 +0100 Subject: [PATCH] Add shared library install target supporting pkgconfig --- CMakeLists.txt | 13 +++++++++++++ adrenotools.pc.in | 13 +++++++++++++ include/adrenotools/driver.h | 1 + 3 files changed, 27 insertions(+) create mode 100644 adrenotools.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 917065f..16c6092 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ endif() project(adrenotools LANGUAGES CXX C) +set(GEN_INSTALL_TARGET OFF CACHE BOOL "") + add_subdirectory(lib/linkernsbypass) set(LIB_SOURCES src/bcenabler.cpp @@ -22,3 +24,14 @@ target_compile_options(adrenotools PRIVATE -Wall -Wextra) target_link_libraries(adrenotools android linkernsbypass) add_subdirectory(src/hook) +if (${BUILD_SHARED_LIBS}) + target_link_options(adrenotools PRIVATE "-Wl,-s,--exclude-libs,liblinkernsbypass.a") +endif() +if (${GEN_INSTALL_TARGET}) + configure_file(adrenotools.pc.in adrenotools.pc @ONLY) + install(FILES ${CMAKE_BINARY_DIR}/adrenotools.pc DESTINATION lib/pkgconfig) + install(TARGETS adrenotools main_hook file_redirect_hook gsl_alloc_hook hook_impl) + install(DIRECTORY include/ + DESTINATION include + FILES_MATCHING PATTERN "*.h*") +endif() diff --git a/adrenotools.pc.in b/adrenotools.pc.in new file mode 100644 index 0000000..1102f43 --- /dev/null +++ b/adrenotools.pc.in @@ -0,0 +1,13 @@ +prefix="@CMAKE_INSTALL_PREFIX@" +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: adrenotools +Description: +URL: +Version: 1.0.0 +Libs: -L${libdir} -ladrenotools +Libs.private: +Requires.private: +Cflags: -I${includedir} diff --git a/include/adrenotools/driver.h b/include/adrenotools/driver.h index 14fc0ba..1749b2f 100644 --- a/include/adrenotools/driver.h +++ b/include/adrenotools/driver.h @@ -7,6 +7,7 @@ extern "C" { #endif +#include #include "priv.h" /**