From 57f8409eaebbf35a25a79d3aeafb8255201dfade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Mairb=C3=B6ck?= Date: Thu, 29 Aug 2024 13:55:16 +0200 Subject: [PATCH 1/2] allow build from src using external zlib This uses `find_package(ZLIB)` when building from source to optionally avoid the submodule and use an installed zlib instead. --- src/CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 36cc421..921fedb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,6 +6,13 @@ set(VERSION 1.0.5) set(CMAKE_C_STANDARD 99) +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) + find_package(ZLIB REQUIRED) + set(zlib_target ZLIB::ZLIB) +else() + set(zlib_target zlib) +endif() + add_library(pplib_utils STATIC util/utilplat.h util/utilcryptdef.h @@ -42,7 +49,7 @@ target_include_directories(pplib_utils PUBLIC target_link_libraries(pplib_utils PUBLIC m - zlib + ${zlib_target} ) add_library(pplib_filters STATIC @@ -63,7 +70,7 @@ target_include_directories(pplib_filters PUBLIC target_link_libraries(pplib_filters PUBLIC m - zlib + ${zlib_target} ) add_library(pplib From d06b165a96cb5dff7c2edea6c3ea1434a5ce5d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Mairb=C3=B6ck?= Date: Thu, 29 Aug 2024 13:58:26 +0200 Subject: [PATCH 2/2] fix installation paths When specifying `DESTINATION lib`, all files get installed there, also the headers, therefore don't specify it so that files get installed in their default location instead. Also include GNUInstallDirs to make the installation paths configurable using standard CMake variables CMAKE_INSTALL_INCLUDEDIR and CMAKE_INSTALL_LIBDIR. --- src/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 921fedb..9819b1f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -138,9 +138,10 @@ set_target_properties(pplib add_library(pplib::pplib ALIAS pplib) +include(GNUInstallDirs) + install(TARGETS pplib EXPORT pplib - DESTINATION lib ) enable_testing()