Merge pull request #40 from rm5248/github-actions-cleanup

GitHub actions and OSX fixes
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..fcadb2c
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text eol=lf
diff --git a/.github/workflows/log4cxx.yml b/.github/workflows/log4cxx.yml
new file mode 100644
index 0000000..ef0dd8e
--- /dev/null
+++ b/.github/workflows/log4cxx.yml
@@ -0,0 +1,91 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+name: log4cxx
+
+on: push
+
+jobs:
+  job:
+    name: ${{ matrix.os }}-${{ matrix.cxx }}-build-and-test
+    runs-on: ${{ matrix.os }}
+    timeout-minutes: 38
+    strategy:
+      fail-fast: false
+      matrix:
+        name: [ubuntu18-gcc, ubuntu18-clang, osx, windows-2019]
+        include:
+          - name: windows-2019
+            os: windows-2019
+            cxx: cl.exe
+            cc: cl.exe
+          - name: ubuntu18-gcc
+            os: ubuntu-18.04
+            cxx: g++
+            cc: gcc
+          - name: ubuntu18-clang
+            os: ubuntu-18.04
+            cxx: clang++
+            cc: clang
+          - name: osx
+            os: macos-latest
+            cxx: clang++
+            cc: clang
+
+    steps:
+    - uses: actions/checkout@v2
+
+    - uses: lukka/set-shell-env@v1
+      with:
+        CXX: ${{ matrix.cxx }}
+        CC: ${{ matrix.cc }}
+
+    - name: 'Configure Dependencies - Ubuntu'
+      if: matrix.name == 'ubuntu18-gcc' || matrix.name == 'ubuntu18-clang'
+      run: |
+        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
+      if: matrix.name == 'windows-2019' || matrix.name == 'windows-2016'
+      uses: actions/cache@v2
+      with:
+        path: ${{ runner.workspace }}/vcpkg
+        key: ${{ runner.os }}-${{ matrix.name }}-cache
+
+    - name: 'Configure Dependencies - Windows'
+      if: matrix.name == 'windows-2019' || matrix.name == 'windows-2016'
+      uses: lukka/run-vcpkg@v2
+      id: runvcpkg
+      with:
+        vcpkgArguments: apr apr-util
+        vcpkgDirectory: ${{ runner.workspace }}/vcpkg/
+        vcpkgGitCommitId: ffa7fd27cfa29f206d1fd2ccfc722cad4aaeef3d
+        vcpkgTriplet: x64-windows
+
+    - name: 'run cmake'
+      uses: lukka/run-cmake@v2
+      with:
+        cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
+        buildDirectory: ${{ runner.workspace }}/build
+        useVcpkgToolchainFile: true
+        cmakeAppendedArgs: '-DLOG4CXX_TEST_PROGRAM_PATH=C:\msys64\usr\bin'
+
+    - name: run unit tests
+      shell: pwsh
+      run: |
+        cd ${{ runner.workspace }}/build
+        ctest -C Debug --output-on-failure -V
diff --git a/.gitignore b/.gitignore
index 6b1565d..dbaf83a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,11 +19,15 @@
 release.properties
 
 autom4te.cache/
+src/.vs
+src/**/__history
 src/main/cpp/.libs/
 src/main/cpp/liblog4cxx.la
 src/main/include/log4cxx/log4cxx.h
 src/main/include/log4cxx/private/log4cxx_private.h
+src/out
 src/site/doxy/Doxyfile
 src/site/doxy/manual/
+src/test/resources/org/
 src/test/resources/output/
 target/
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9a450b7..aa2d16e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,6 +4,7 @@
 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
+cmake_policy(SET CMP0079 NEW)
 target_link_libraries(log4cxx PRIVATE odbc32.lib)
 option(LOG4CXX_INSTALL_PDB "Install .pdb files (if generated)"  ON)
 endif()
diff --git a/src/cmake/FindAPR-Util.cmake b/src/cmake/FindAPR-Util.cmake
index b2da4b4..d9cf4df 100644
--- a/src/cmake/FindAPR-Util.cmake
+++ b/src/cmake/FindAPR-Util.cmake
@@ -29,7 +29,7 @@
 
 find_program(APR_UTIL_CONFIG_EXECUTABLE
     apu-1-config
-    PATHS /usr/local/bin    /usr/bin    C:/Progra~1/apr-util/bin
+    PATHS /usr/local/bin    /usr/local/opt/apr-util/bin    /usr/bin    $ENV{ProgramFiles}/apr-util/bin
     )
 mark_as_advanced(APR_UTIL_CONFIG_EXECUTABLE)
 if(EXISTS ${APR_UTIL_CONFIG_EXECUTABLE})
diff --git a/src/cmake/FindAPR.cmake b/src/cmake/FindAPR.cmake
index a204ece..73876c4 100644
--- a/src/cmake/FindAPR.cmake
+++ b/src/cmake/FindAPR.cmake
@@ -28,7 +28,7 @@
 
 find_program(APR_CONFIG_EXECUTABLE
     apr-1-config
-    PATHS /usr/local/bin    /usr/bin    C:/Progra~1/apr/bin
+    PATHS /usr/local/bin    /usr/local/opt/apr/bin    /usr/bin    $ENV{ProgramFiles}/apr/bin
     )
 mark_as_advanced(APR_CONFIG_EXECUTABLE)
 if(EXISTS ${APR_CONFIG_EXECUTABLE})
diff --git a/src/main/cpp/logstream.cpp b/src/main/cpp/logstream.cpp
index de9a763..29c3bcf 100644
--- a/src/main/cpp/logstream.cpp
+++ b/src/main/cpp/logstream.cpp
@@ -35,6 +35,9 @@
 	//
 	memset(this, 0, sizeof(*this));
 #endif
+#if LOG4CXX_INIT_IOS_BASE
+	init(NULL);
+#endif
 	flags(initval);
 	precision(initsize);
 	width(initsize);
diff --git a/src/main/include/CMakeLists.txt b/src/main/include/CMakeLists.txt
index d1a0bb2..a8b0f40 100644
--- a/src/main/include/CMakeLists.txt
+++ b/src/main/include/CMakeLists.txt
@@ -34,8 +34,10 @@
 endif()
 option(LOG4CXX_WCHAR_T "Enable wchar_t API methods" ON)
 option(LOG4CXX_UNICHAR "Enable UniChar API methods" OFF)
+set(INIT_IOS_BASE 0)
 if(APPLE)
 option(LOG4CXX_CFSTRING "Enable CFString API methods, requires Mac OS/X CoreFoundation" OFF)
+set(INIT_IOS_BASE 1)
 endif()
 set(CHAR_API 1)
 foreach(varName WCHAR_T  UNICHAR  CFSTRING )
diff --git a/src/main/include/log4cxx/private/log4cxx_private.h.in b/src/main/include/log4cxx/private/log4cxx_private.h.in
index e21f4d8..53e59ef 100644
--- a/src/main/include/log4cxx/private/log4cxx_private.h.in
+++ b/src/main/include/log4cxx/private/log4cxx_private.h.in
@@ -40,6 +40,7 @@
 #define LOG4CXX_HAS_MBSRTOWCS @HAS_MBSRTOWCS@
 #define LOG4CXX_HAS_WCSTOMBS @HAS_WCSTOMBS@
 #define LOG4CXX_HAS_FWIDE @HAS_FWIDE@
+#define LOG4CXX_INIT_IOS_BASE @INIT_IOS_BASE@
 
 #define LOG4CXX_CHARSET_UTF8 @CHARSET_UTF8@
 #define LOG4CXX_CHARSET_ISO88591 @CHARSET_ISO88591@
diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt
index b236072..386af20 100644
--- a/src/test/cpp/CMakeLists.txt
+++ b/src/test/cpp/CMakeLists.txt
@@ -93,10 +93,9 @@
         COMMAND ${testName} -v
         WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../resources
     )
-	  set_tests_properties( ${testName} PROPERTIES TIMEOUT 120 )
+    set_tests_properties( ${testName} PROPERTIES TIMEOUT 120 )
 
     if(WIN32)
-
         if(${testName} STREQUAL socketservertestcase)
             set_tests_properties(socketservertestcase PROPERTIES
                 ENVIRONMENT "SOCKET_SERVER_PARAMETER_FILE=${START_SOCKET_SERVER_PARAMETER_FILE};PATH=${ESCAPED_PATH}"