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


The following commit(s) were added to refs/heads/master by this push:
     new ab16767a Improve build messages when ODBCAppender is enabled (#342)
ab16767a is described below

commit ab16767acbaed69ef3af38793fda3840f02c3ba6
Author: Stephen Webb <[email protected]>
AuthorDate: Thu Feb 1 15:50:49 2024 +1100

    Improve build messages when ODBCAppender is enabled (#342)
    
    * Some macos-11 CI machines do not have odbc installed
    
    * Prevent 'unused CMAKE_C_COMPILER' warning
---
 .github/workflows/log4cxx-macos.yml |  4 +++-
 src/cmake/FindODBC.cmake            | 18 ++++++++++++------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/log4cxx-macos.yml 
b/.github/workflows/log4cxx-macos.yml
index bdc5f75e..456a191a 100644
--- a/.github/workflows/log4cxx-macos.yml
+++ b/.github/workflows/log4cxx-macos.yml
@@ -30,10 +30,12 @@ jobs:
             os: macos-11
             cxx: clang++
             cc: clang
+            odbc: OFF
           - name: osx-12
             os: macos-12
             cxx: clang++
             cc: clang
+            odbc: ON
 
     steps:
     - uses: actions/checkout@v3
@@ -45,7 +47,7 @@ jobs:
         cd main
         mkdir build
         cd build
-        cmake -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DCMAKE_C_COMPILER=${{ 
matrix.cc }} -DLOG4CXX_ENABLE_ODBC=ON -DLOG4CXX_CFSTRING=ON 
-DCMAKE_BUILD_TYPE=Debug ..
+        cmake -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} -DLOG4CXX_ENABLE_ODBC=${{ 
matrix.odbc }} -DLOG4CXX_CFSTRING=ON -DCMAKE_BUILD_TYPE=Debug ..
         cmake --build .
 
     - name: run unit tests
diff --git a/src/cmake/FindODBC.cmake b/src/cmake/FindODBC.cmake
index 95bb5952..5d3d3b3d 100644
--- a/src/cmake/FindODBC.cmake
+++ b/src/cmake/FindODBC.cmake
@@ -4,7 +4,8 @@ include(FindPackageHandleStandardArgs)
 # This module defines
 # ODBC_INCLUDE_DIR, where to find odbc.h, etc.
 # ODBC_LIBRARIES, the libraries to link against to use odbc.
-# ODBC_FOUND, set to 'yes' if found
+# ODBC_FOUND, set to 1 if found
+set(ODBC_FOUND 0)
 if(WIN32)
   set(ODBC_LIBRARIES odbc32.lib user32.lib)
   try_compile(ODBC_FOUND "${CMAKE_BINARY_DIR}/find-odbc"
@@ -15,15 +16,17 @@ else()
   if(NOT ODBC_STATIC) # 'pkg-config --static odbc' does not provide libodbc.a 
file path
     find_package(PkgConfig)
     pkg_check_modules(odbc odbc)
-  else()
-    set(odbc_FOUND 0)
+    set(ODBC_FOUND ${odbc_FOUND})
   endif()
-  #message("odbc_FOUND=${odbc_FOUND}")
+  #message("ODBC_FOUND=${ODBC_FOUND}")
 
-  if(odbc_FOUND)
+  if(ODBC_FOUND)
+    #message("odbc_INCLUDE_DIRS=${odbc_INCLUDE_DIRS}")
+    #message("odbc_LINK_LIBRARIES=${odbc_LINK_LIBRARIES}")
+    #message("odbc_STATIC_LINK_LIBRARIES=${odbc_STATIC_LINK_LIBRARIES}")
     find_path(ODBC_INCLUDE_DIR
               NAMES odbcinst.h
-              HINTS ${ODBC_INCLUDE_DIRS}
+              HINTS ${odbc_INCLUDE_DIRS}
               PATH_SUFFIXES odbc)
     if (ODBC_STATIC OR NOT BUILD_SHARED_LIBS)
       set(ODBC_LIBRARIES ${odbc_STATIC_LINK_LIBRARIES})
@@ -37,6 +40,9 @@ else()
     else()
       find_library(ODBC_LIBRARIES NAMES odbc HINTS ${ODBC_LIBRARY_DIRS} )
     endif()
+    if(ODBC_INCLUDE_DIR AND ODBC_LIBRARIES)
+      set(ODBC_FOUND 1)
+    endif()
   endif()
 
   #message("ODBC_INCLUDE_DIR=${ODBC_INCLUDE_DIR}")

Reply via email to