You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ts...@apache.org on 2020/05/04 08:18:22 UTC

[logging-log4cxx] branch master updated: Static linking support for non windows systems (#23)

This is an automated email from the ASF dual-hosted git repository.

tschoening pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/master by this push:
     new 400f15c  Static linking support for non windows systems (#23)
400f15c is described below

commit 400f15c3052fed61e1ae8363a61debbb93de45a9
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Mon May 4 18:18:15 2020 +1000

    Static linking support for non windows systems (#23)
    
    Add support for statically linking the APR and APR-Util libraries on non-Windows systems.
---
 src/cmake/FindAPR-Util.cmake | 12 ++++++++++--
 src/cmake/FindAPR.cmake      | 10 +++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/cmake/FindAPR-Util.cmake b/src/cmake/FindAPR-Util.cmake
index 4f07c93..bb4e951 100644
--- a/src/cmake/FindAPR-Util.cmake
+++ b/src/cmake/FindAPR-Util.cmake
@@ -34,7 +34,15 @@ find_program(APR_UTIL_CONFIG_EXECUTABLE
 mark_as_advanced(APR_UTIL_CONFIG_EXECUTABLE)
 if(EXISTS ${APR_UTIL_CONFIG_EXECUTABLE})
     _apu_invoke(APR_UTIL_INCLUDE_DIR   --includedir)
-    _apu_invoke(APR_UTIL_LIBRARIES     --link-ld)
+    if (APU_STATIC OR NOT BUILD_SHARED_LIBS)
+      _apu_invoke(_apu_util_link_args  --link-ld)
+      string(REGEX MATCH "-L([^ ]+)" _apu_util_L_flag ${_apu_util_link_args})
+      find_library(APR_UTIL_LIBRARIES NAMES libaprutil-1.a PATHS "${CMAKE_MATCH_1}")
+      _apu_invoke(XMLLIB_LIBRARIES --libs)
+      set(APR_UTIL_COMPILE_DEFINITIONS APU_DECLARE_STATIC)
+    else()
+      _apu_invoke(APR_UTIL_LIBRARIES   --link-ld)
+    endif()
 else()
     find_path(APR_UTIL_INCLUDE_DIR apu.h PATH_SUFFIXES apr-1)
     if (APU_STATIC OR NOT BUILD_SHARED_LIBS)
@@ -48,5 +56,5 @@ else()
     endif()
 endif()
 
-find_package_handle_standard_args(APR-Util DEFAULT_MSG
+find_package_handle_standard_args(APR-Util
   APR_UTIL_INCLUDE_DIR APR_UTIL_LIBRARIES)
diff --git a/src/cmake/FindAPR.cmake b/src/cmake/FindAPR.cmake
index 92eaa98..a204ece 100644
--- a/src/cmake/FindAPR.cmake
+++ b/src/cmake/FindAPR.cmake
@@ -33,7 +33,15 @@ find_program(APR_CONFIG_EXECUTABLE
 mark_as_advanced(APR_CONFIG_EXECUTABLE)
 if(EXISTS ${APR_CONFIG_EXECUTABLE})
     _apr_invoke(APR_INCLUDE_DIR  --includedir)
-    _apr_invoke(APR_LIBRARIES  --link-ld)
+    if (APR_STATIC OR NOT BUILD_SHARED_LIBS)
+      _apr_invoke(_apr_link_args  --link-ld)
+      string(REGEX MATCH "-L([^ ]+)" _apr_L_flag ${_apr_link_args})
+      find_library(APR_LIBRARIES NAMES libapr-1.a PATHS "${CMAKE_MATCH_1}")
+      set(APR_SYSTEM_LIBS  pthread)
+      set(APR_COMPILE_DEFINITIONS APR_DECLARE_STATIC)
+    else()
+      _apr_invoke(APR_LIBRARIES  --link-ld)
+    endif()
 else()
     find_path(APR_INCLUDE_DIR apr.h PATH_SUFFIXES apr-1)
     if (APR_STATIC OR NOT BUILD_SHARED_LIBS)