From f64063bf1dff1f05f95b11d4571ad6416faa81ae Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Wed, 17 May 2023 09:09:53 +0200 Subject: build: add static lib only if necessary (#479) adding static library should only be enabled if the dlt library is build static. Adding this to the automotive-dlt.pc.in when static libraries are disabled yocto build will break Signed-off-by: Alexander Mohr --- CMakeLists.txt | 6 ++++++ automotive-dlt.pc.in | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57044d6..ff53ceb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,6 +209,12 @@ else() set(PACKAGE_DOC "") endif() +if (BUILD_SHARED_LIBS) + set(CMAKE_STATIC_LIB_PATH "") +else() + set(CMAKE_STATIC_LIB_PATH "-L\$\{libdir\}/static") +endif() + if(WITH_DLT_PKGCONFIG) configure_file(${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.spec.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.spec) configure_file(${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY) diff --git a/automotive-dlt.pc.in b/automotive-dlt.pc.in index 568b102..ddca060 100644 --- a/automotive-dlt.pc.in +++ b/automotive-dlt.pc.in @@ -22,6 +22,6 @@ Name: DLT Description: Diagnostic Log and Trace Version: @PROJECT_VERSION@ Requires: -Libs: -L${libdir} -L${libdir}/static -ldlt -lrt -lpthread @ZLIB_LIBRARY@ +Libs: -L${libdir} @CMAKE_STATIC_LIB_PATH@ -ldlt -lrt -lpthread @ZLIB_LIBRARY@ Cflags: -I${includedir}/dlt -I${includedir} -DDLT_@PROJECT_VERSION_MAJOR@_@PROJECT_VERSION_MINOR@ -- cgit v1.2.1