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 2020/09/06 16:52:09 UTC
[logging-log4cxx] branch master updated: LOGCXX-510 Get correct
path for building on win32 (#39)
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 a7d5628 LOGCXX-510 Get correct path for building on win32 (#39)
a7d5628 is described below
commit a7d562806f0512683d9f32b3c3f95300d4c62fbe
Author: Robert Middleton <rm...@users.noreply.github.com>
AuthorDate: Sun Sep 6 09:52:01 2020 -0700
LOGCXX-510 Get correct path for building on win32 (#39)
---
.editorconfig | 9 +++++++++
CMakeLists.txt | 3 +++
src/CMakeLists.txt | 2 +-
src/cmake/FindAPR-Util.cmake | 2 --
src/site/apt/building/cmake.apt | 15 +++++++++++++++
src/test/cpp/CMakeLists.txt | 39 ++++++++++++++++++++++++++++++++-------
src/test/cpp/xml/CMakeLists.txt | 2 +-
7 files changed, 61 insertions(+), 11 deletions(-)
diff --git a/.editorconfig b/.editorconfig
index c013fc3..4836cb6 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -26,3 +26,12 @@ indent_style = space
insert_final_newline = true
tab_width = 2
trim_trailing_whitespace = true
+
+[CMakeLists.txt]
+charset = utf-8
+end_of_line = lf
+indent_size = 2
+indent_style = space
+insert_final_newline = true
+tab_width = 2
+trim_trailing_whitespace = true
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4763cfa..b728ff7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,9 @@ find_package(APR REQUIRED)
# Find Apache Runtime Utilities
find_package(APR-Util REQUIRED)
+# Find expat for XML parsing
+find_package(EXPAT REQUIRED)
+
# Building
add_subdirectory(src)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3e0cb17..9a450b7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,7 @@
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::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)
diff --git a/src/cmake/FindAPR-Util.cmake b/src/cmake/FindAPR-Util.cmake
index bb4e951..b2da4b4 100644
--- a/src/cmake/FindAPR-Util.cmake
+++ b/src/cmake/FindAPR-Util.cmake
@@ -48,8 +48,6 @@ else()
if (APU_STATIC OR NOT BUILD_SHARED_LIBS)
set(APR_UTIL_COMPILE_DEFINITIONS APU_DECLARE_STATIC)
find_library(APR_UTIL_LIBRARIES NAMES aprutil-1)
- find_library(XMLLIB_LIBRARIES NAMES libexpat)
- find_program(XMLLIB_DLL libexpat.dll)
else()
find_library(APR_UTIL_LIBRARIES NAMES libaprutil-1)
find_program(APR_UTIL_DLL libaprutil-1.dll)
diff --git a/src/site/apt/building/cmake.apt b/src/site/apt/building/cmake.apt
index fbbecac..9bfb794 100644
--- a/src/site/apt/building/cmake.apt
+++ b/src/site/apt/building/cmake.apt
@@ -57,6 +57,9 @@ $ sudo make install
| -DAPR_STATIC=yes | Link to the APR static library. By default, the log4cxx shared library is linked to the |
| | APR shared library. If BUILD_SHARED_LIBS=off, the static APR library is always used. |
*------------------------+---------------------------------------------------------------------------------------------+
+|-DLOG4CXX_TEST_PROGRAM_PATH=path| An extra path to prepend to the PATH for test programs. Log4cxx requires zip, |
+| | sed, and grep on the PATH in order for the tests to work properly. |
+*------------------------+---------------------------------------------------------------------------------------------+
Building and testing log4cxx on a Microsoft Windows with APR, Expat and APR-Util built from source
extracted into apr-1.7.0, libexpat(from github) and apr-util-1.6.1 in %HOMEPATH%\Libraries.
@@ -117,6 +120,18 @@ $ make
$ make install
+----+
+** Windows:
+
+The easiest way to get dependencies installed is to use vcpkg(for APR/expat), and msys2 for the command-line
+utilities(zip, grep, sed).
+
+Msys2 can be downloaded from: https://www.msys2.org/
+By default, this will be installed under C:\msys2, so you can add that to the build PATH by setting
+LOG4CXX_TEST_PROGRAM_PATH=C:/msys64/usr/bin in your build settings.
+
+For vcpkg, follow the directions at https://github.com/microsoft/vcpkg#quick-start-windows and then install
+the dependencies needed using `vcpkg install apr apr-util`.
+
* Using log4cxx in a CMake build
A log4cxxConfig.cmake and log4cxxConfigVersion.cmake is installed to allow use of find_package()
diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt
index b63c20d..b236072 100644
--- a/src/test/cpp/CMakeLists.txt
+++ b/src/test/cpp/CMakeLists.txt
@@ -5,6 +5,9 @@ target_include_directories(testingFramework PRIVATE ${CMAKE_CURRENT_LIST_DIR} $<
add_subdirectory(util)
target_sources(testingUtilities PRIVATE xml/xlevel.cpp)
+set( LOG4CXX_TEST_PROGRAM_PATH "" CACHE PATH "Extra path for test programs" )
+set( CMAKE_PROGRAM_PATH "${LOG4CXX_TEST_PROGRAM_PATH};${CMAKE_PROGRAM_PATH}" )
+
# sed, zip, and gzip are needed for the tests to work properly
# Note: option 'required' not available until cmake 3.18, however adding
# it does not cause an issue
@@ -57,6 +60,31 @@ add_subdirectory(spi)
add_subdirectory(varia)
add_subdirectory(xml)
+# Note: we need to include the APR DLLs on our path so that the tests will run.
+# The way that CMake sets the environment is that it actually generates a secondary file,
+# CTestTestfile.cmake, which sets the final properties of the test.
+# However, this results in a secondary quirk to the running of the tests: CMake uses
+# a semicolon to deliminate entries in a list! Since the Windows PATH is semicolon-delimited
+# as well, CMake uses only the first entry in the list when setting the path.
+# So, we need to do a triple escape on the PATH that we want to set in order for CMake to
+# properly interpret the PATH
+if( WIN32 )
+ get_filename_component(APR_DLL_DIR "${APR_DLL}" DIRECTORY)
+ get_filename_component(APR_UTIL_DLL_DIR "${APR_UTIL_DLL}" DIRECTORY)
+ get_filename_component(EXPAT_LIB_DIR "${EXPAT_LIBRARY}" DIRECTORY)
+
+
+ set(EXPAT_DLL_DIR "${EXPAT_LIB_DIR}/../bin")
+ set(LOG4CXX_DLL_DIR "$<SHELL_PATH:$<TARGET_FILE_DIR:log4cxx>>;")
+ set(PATH_FOR_TESTS ${CMAKE_PROGRAM_PATH};${APR_DLL_DIR};${APR_UTIL_DLL_DIR};${LOG4CXX_DLL_DIR};${EXPAT_DLL_DIR}\;)
+ list(REMOVE_DUPLICATES PATH_FOR_TESTS)
+ set(NORMAL_PATH $ENV{PATH})
+ set(ESCAPED_PATH "")
+ foreach( ENTRY ${PATH_FOR_TESTS}${NORMAL_PATH} )
+ set(ESCAPED_PATH "${ESCAPED_PATH}${ENTRY}\\\;")
+ endforeach()
+endif( WIN32 )
+
foreach(testName IN LISTS ALL_LOG4CXX_TESTS)
target_compile_definitions(${testName} PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} )
target_include_directories(${testName} PRIVATE ${CMAKE_CURRENT_LIST_DIR} $<TARGET_PROPERTY:log4cxx,INCLUDE_DIRECTORIES>)
@@ -65,20 +93,17 @@ foreach(testName IN LISTS ALL_LOG4CXX_TESTS)
COMMAND ${testName} -v
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../resources
)
+ set_tests_properties( ${testName} PROPERTIES TIMEOUT 120 )
if(WIN32)
- get_filename_component(APR_DLL_DIR "${APR_DLL}" DIRECTORY)
- get_filename_component(APR_UTIL_DLL_DIR "${APR_UTIL_DLL}" DIRECTORY)
- get_filename_component(XMLLIB_DLL_DIR "${XMLLIB_DLL}" DIRECTORY)
- set(PATH_FOR_TESTS $<SHELL_PATH:$<TARGET_FILE_DIR:log4cxx>> ${APR_DLL_DIR} ${APR_UTIL_DLL_DIR} ${XMLLIB_DLL_DIR})
- list(REMOVE_DUPLICATES PATH_FOR_TESTS)
+
if(${testName} STREQUAL socketservertestcase)
set_tests_properties(socketservertestcase PROPERTIES
- ENVIRONMENT "SOCKET_SERVER_PARAMETER_FILE=${START_SOCKET_SERVER_PARAMETER_FILE};PATH=${LOG4CXX_DLL_DIR}\;${APR_DLL_DIR}\;${APR_UTIL_DLL_DIR}"
+ ENVIRONMENT "SOCKET_SERVER_PARAMETER_FILE=${START_SOCKET_SERVER_PARAMETER_FILE};PATH=${ESCAPED_PATH}"
)
else()
set_tests_properties(${testName} PROPERTIES
- ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2;PATH==${LOG4CXX_DLL_DIR}\;${APR_DLL_DIR}\;${APR_UTIL_DLL_DIR}"
+ ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2;PATH=${ESCAPED_PATH}"
)
endif()
else()
diff --git a/src/test/cpp/xml/CMakeLists.txt b/src/test/cpp/xml/CMakeLists.txt
index bddfe48..138c489 100644
--- a/src/test/cpp/xml/CMakeLists.txt
+++ b/src/test/cpp/xml/CMakeLists.txt
@@ -4,5 +4,5 @@ add_executable(xmltests
xmllayouttestcase
)
-target_link_libraries(xmltests PRIVATE ${APR_UTIL_LIBRARIES} ${XMLLIB_LIBRARIES})
+target_link_libraries(xmltests PRIVATE ${APR_UTIL_LIBRARIES} EXPAT::EXPAT)
set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} xmltests PARENT_SCOPE)