You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rm...@apache.org on 2021/04/01 00:24:49 UTC
[logging-log4cxx] branch master updated: Logcxx-521 (#59)
This is an automated email from the ASF dual-hosted git repository.
rmiddleton 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 f6f4fe3 Logcxx-521 (#59)
f6f4fe3 is described below
commit f6f4fe3a41f9bb937c5063db739369aa9ecda5ff
Author: Robert Middleton <rm...@users.noreply.github.com>
AuthorDate: Wed Mar 31 20:24:40 2021 -0400
Logcxx-521 (#59)
* Link cleanly with ODBC on Linux
---
.github/workflows/log4cxx.yml | 2 --
src/CMakeLists.txt | 12 +++++++++---
src/main/include/CMakeLists.txt | 12 +++++++++++-
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/log4cxx.yml b/.github/workflows/log4cxx.yml
index ac725c0..1233d19 100644
--- a/.github/workflows/log4cxx.yml
+++ b/.github/workflows/log4cxx.yml
@@ -53,8 +53,6 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y libapr1-dev libaprutil1-dev
- # note: sqlext.h exists on github VM, purge for now as we don't link correctly...
- sudo apt-get purge unixodbc-dev
- name: 'Restore Prebuilt Dependencies - Windows'
id: restore-vcpkg-cache
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 283283c..b60e54f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,9 +5,15 @@ target_compile_definitions(log4cxx PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_
target_include_directories(log4cxx INTERFACE $<INSTALL_INTERFACE:include> PRIVATE ${APR_INCLUDE_DIR} ${APR_UTIL_INCLUDE_DIR})
target_link_libraries(log4cxx PRIVATE ${APR_UTIL_LIBRARIES} EXPAT::EXPAT ${APR_LIBRARIES} ${APR_SYSTEM_LIBS})
if(WIN32)
-# The ODBC appender is always enabled in the Windows configuration
-target_link_libraries(log4cxx PRIVATE odbc32.lib)
-option(LOG4CXX_INSTALL_PDB "Install .pdb files (if generated)" ON)
+ # The ODBC appender is always enabled in the Windows configuration
+ target_link_libraries(log4cxx PRIVATE odbc32.lib)
+ option(LOG4CXX_INSTALL_PDB "Install .pdb files (if generated)" ON)
+else()
+ if(${odbc_FOUND})
+ target_include_directories(log4cxx PRIVATE ${odbc_INCLUDE_DIRS})
+ target_link_directories( log4cxx PRIVATE ${odbc_LIBRARY_DIRS})
+ target_link_libraries( log4cxx PRIVATE ${odbc_LIBRARIES})
+ endif(${odbc_FOUND})
endif()
if(BUILD_TESTING)
diff --git a/src/main/include/CMakeLists.txt b/src/main/include/CMakeLists.txt
index 5659f2a..a596d4b 100644
--- a/src/main/include/CMakeLists.txt
+++ b/src/main/include/CMakeLists.txt
@@ -68,8 +68,18 @@ include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
+if(WIN32)
+ CHECK_INCLUDE_FILES(sqlext.h HAS_ODBC)
+else()
+ include(FindPkgConfig)
+
+ pkg_check_modules( odbc QUIET odbc )
+ if(${odbc_FOUND})
+ set(HAS_ODBC 1)
+ endif(${odbc_FOUND})
+endif(WIN32)
+
CHECK_INCLUDE_FILE_CXX(locale HAS_STD_LOCALE)
-CHECK_INCLUDE_FILES(sqlext.h HAS_ODBC)
CHECK_FUNCTION_EXISTS(mbsrtowcs HAS_MBSRTOWCS)
CHECK_FUNCTION_EXISTS(wcstombs HAS_WCSTOMBS)
CHECK_FUNCTION_EXISTS(fwide HAS_FWIDE)