You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2022/01/18 00:43:01 UTC

[logging-log4cxx] 02/02: Allow expat dependency to be found by either the cmake shipped script or the expat config module

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

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

commit e1b363fc9405ac0728cfeac104a3aa729de1c7bd
Author: Stephen Webb <st...@sabreautonomous.com.au>
AuthorDate: Mon Jan 17 16:15:05 2022 +1100

    Allow expat dependency to be found by either the cmake shipped script or the expat config module
---
 CMakeLists.txt                  | 6 +++++-
 src/CMakeLists.txt              | 2 +-
 src/cmake/FindAPR-Util.cmake    | 1 -
 src/examples/cpp/CMakeLists.txt | 4 ++--
 src/test/cpp/xml/CMakeLists.txt | 2 +-
 5 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 529a880..71c871f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,7 +50,11 @@ find_package( Threads REQUIRED )
 
 # Find expat for XML parsing
 find_package(EXPAT REQUIRED)
-set(XMLLIB_LIBRARIES EXPAT::EXPAT)
+if(TARGET EXPAT::EXPAT)
+  set(EXPAT_LIBRARIES EXPAT::EXPAT)
+elseif(TARGET expat::expat)
+  set(EXPAT_LIBRARIES expat::expat)
+endif()
 
 # Request C++17, if available
 # This *should* fallback to an older standard if it is not available
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cf9f708..c037bb8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -19,7 +19,7 @@ cmake_policy(SET CMP0079 NEW)
 add_subdirectory(main)
 target_compile_definitions(log4cxx PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} )
 target_include_directories(log4cxx INTERFACE $<INSTALL_INTERFACE:include> PRIVATE ${APR_INCLUDE_DIR} ${APR_UTIL_INCLUDE_DIR})
-target_link_libraries(log4cxx PRIVATE ${APR_UTIL_LIBRARIES} ${XMLLIB_LIBRARIES} ${APR_LIBRARIES} ${APR_SYSTEM_LIBS})
+target_link_libraries(log4cxx PRIVATE ${APR_UTIL_LIBRARIES} ${EXPAT_LIBRARIES} ${APR_LIBRARIES} ${APR_SYSTEM_LIBS})
 if(WIN32)
 	# The ODBC appender is always enabled in the Windows configuration
 	target_link_libraries(log4cxx PRIVATE odbc32.lib)
diff --git a/src/cmake/FindAPR-Util.cmake b/src/cmake/FindAPR-Util.cmake
index d9cf4df..17a2457 100644
--- a/src/cmake/FindAPR-Util.cmake
+++ b/src/cmake/FindAPR-Util.cmake
@@ -38,7 +38,6 @@ if(EXISTS ${APR_UTIL_CONFIG_EXECUTABLE})
       _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)
diff --git a/src/examples/cpp/CMakeLists.txt b/src/examples/cpp/CMakeLists.txt
index 377079e..cfb2fe7 100644
--- a/src/examples/cpp/CMakeLists.txt
+++ b/src/examples/cpp/CMakeLists.txt
@@ -21,7 +21,7 @@ foreach(exampleName IN LISTS ALL_LOG4CXX_EXAMPLES)
     add_executable(${exampleName} ${exampleName}.cpp)
     target_compile_definitions(${exampleName} PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} )
     target_include_directories(${exampleName} PRIVATE ${CMAKE_CURRENT_LIST_DIR} $<TARGET_PROPERTY:log4cxx,INCLUDE_DIRECTORIES>)
-    target_link_libraries(${exampleName} PRIVATE log4cxx ${APR_UTIL_LIBRARIES} ${XMLLIB_LIBRARIES} ${APR_LIBRARIES} ${APR_SYSTEM_LIBS})
+    target_link_libraries(${exampleName} PRIVATE log4cxx ${APR_UTIL_LIBRARIES} ${EXPAT_LIBRARIES} ${APR_LIBRARIES} ${APR_SYSTEM_LIBS})
 endforeach()
 
 configure_file( custom-appender.xml
@@ -34,5 +34,5 @@ if(${fmt_FOUND})
     add_executable( format-string format-string.cpp )
     target_compile_definitions(format-string PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} )
     target_include_directories(format-string PRIVATE ${CMAKE_CURRENT_LIST_DIR} $<TARGET_PROPERTY:log4cxx,INCLUDE_DIRECTORIES>)
-    target_link_libraries(format-string PRIVATE log4cxx ${APR_UTIL_LIBRARIES} ${XMLLIB_LIBRARIES} ${APR_LIBRARIES} ${APR_SYSTEM_LIBS} fmt::fmt)
+    target_link_libraries(format-string PRIVATE log4cxx ${APR_UTIL_LIBRARIES} ${EXPAT_LIBRARIES} ${APR_LIBRARIES} ${APR_SYSTEM_LIBS} fmt::fmt)
 endif(${fmt_FOUND})
diff --git a/src/test/cpp/xml/CMakeLists.txt b/src/test/cpp/xml/CMakeLists.txt
index f7828dc..6a20d73 100644
--- a/src/test/cpp/xml/CMakeLists.txt
+++ b/src/test/cpp/xml/CMakeLists.txt
@@ -21,5 +21,5 @@ add_executable(xmltests
     xmllayouttestcase.cpp
 )
 
-target_link_libraries(xmltests PRIVATE ${APR_UTIL_LIBRARIES} ${XMLLIB_LIBRARIES})
+target_link_libraries(xmltests PRIVATE ${APR_UTIL_LIBRARIES} ${EXPAT_LIBRARIES})
 set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} xmltests PARENT_SCOPE)