You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ts...@apache.org on 2020/02/09 20:20:24 UTC
[logging-log4cxx] 44/49: Allow tests on Windows to be run from ctest
This is an automated email from the ASF dual-hosted git repository.
tschoening pushed a commit to branch ghpr_14_replace-ant-build-with-cmake
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 178598b7e5be9f8a5704e20ea752c1ee438b5aca
Author: Stephen Webb <st...@sabreautonomous.com.au>
AuthorDate: Sun Feb 9 18:19:46 2020 +1100
Allow tests on Windows to be run from ctest
---
CMakeLists.txt | 6 ------
src/cmake/FindAPR-Util.cmake | 5 +++++
src/cmake/FindAPR.cmake | 5 +++++
src/test/cpp/CMakeLists.txt | 32 ++++++++++++++++++++------------
4 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0b46e1e..280d50d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,15 +8,9 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/src/cmake")
# Find Apache Runtime
find_package(APR QUIET)
-# If APR find module sets the cache, the following will do nothing
-find_path(APR_INCLUDE_DIR apr.h PATH_SUFFIXES apr-1)
-find_library(APR_LIBRARIES NAMES libapr-1 apr-1)
# Find Apache Runtime Utilities
find_package(APR-Util QUIET)
-# If APR-UTIL find module sets the cache, the following will do nothing
-find_path(APR_UTIL_INCLUDE_DIR apu.h PATH_SUFFIXES apr-1)
-find_library(APR_UTIL_LIBRARIES NAMES libaprutil-1 aprutil-1)
# Building
add_subdirectory(src)
diff --git a/src/cmake/FindAPR-Util.cmake b/src/cmake/FindAPR-Util.cmake
index 3485911..9b1ec68 100644
--- a/src/cmake/FindAPR-Util.cmake
+++ b/src/cmake/FindAPR-Util.cmake
@@ -4,6 +4,7 @@ include(FindPackageHandleStandardArgs)
# This module defines
# APR_UTIL_INCLUDE_DIR, where to find apr.h, etc.
# APR_UTIL_LIBRARIES, the libraries to link against to use APR.
+# APR_UTIL_DLL_DIR, where to find libaprutil-1.dll
# APR_UTIL_FOUND, set to yes if found
macro(_apu_invoke _varname)
@@ -34,6 +35,10 @@ mark_as_advanced(APR_UTIL_CONFIG_EXECUTABLE)
if(EXISTS ${APR_UTIL_CONFIG_EXECUTABLE})
_apu_invoke(APR_UTIL_INCLUDE_DIR --includedir)
_apu_invoke(APR_UTIL_LIBRARIES --link-ld)
+else()
+ find_path(APR_UTIL_INCLUDE_DIR apu.h PATH_SUFFIXES apr-1)
+ find_library(APR_UTIL_LIBRARIES NAMES libaprutil-1 aprutil-1)
+ find_path(APR_UTIL_DLL_DIR libaprutil-1.dll)
endif()
find_package_handle_standard_args(apr-util DEFAULT_MSG
diff --git a/src/cmake/FindAPR.cmake b/src/cmake/FindAPR.cmake
index 171d745..7678519 100644
--- a/src/cmake/FindAPR.cmake
+++ b/src/cmake/FindAPR.cmake
@@ -4,6 +4,7 @@ include(FindPackageHandleStandardArgs)
# This module defines
# APR_INCLUDE_DIR, where to find apr.h, etc.
# APR_LIBRARIES, the libraries to link against to use APR.
+# APR_DLL_DIR, where to find libapr-1.dll
# APR_FOUND, set to 'yes' if found
macro(_apr_invoke _varname)
execute_process(
@@ -33,6 +34,10 @@ mark_as_advanced(APR_CONFIG_EXECUTABLE)
if(EXISTS ${APR_CONFIG_EXECUTABLE})
_apr_invoke(APR_INCLUDE_DIR --includedir)
_apr_invoke(APR_LIBRARIES --link-ld)
+else()
+ find_path(APR_INCLUDE_DIR apr.h PATH_SUFFIXES apr-1)
+ find_library(APR_LIBRARIES NAMES libapr-1 apr-1)
+ find_path(APR_DLL_DIR libapr-1.dll)
endif()
find_package_handle_standard_args(apr
diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt
index bbe01e3..8d5cfbe 100644
--- a/src/test/cpp/CMakeLists.txt
+++ b/src/test/cpp/CMakeLists.txt
@@ -57,18 +57,26 @@ foreach(testName IN LISTS ALL_LOG4CXX_TESTS)
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../resources
)
- if(${testName} STREQUAL socketservertestcase)
- set_tests_properties(socketservertestcase PROPERTIES
- ENVIRONMENT "SOCKET_SERVER_COMMAND=$<JOIN:${START_SOCKET_SERVER_COMMAND}, >"
- )
- else()
- set_tests_properties(${testName} PROPERTIES
- ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2"
- )
- endif()
if(WIN32)
- set_tests_properties(${testName} PROPERTIES ENVIRONMENT
- "PATH=$<SHELL_PATH:$<TARGET_FILE_DIR:log4cxx>>$<SEMICOLON>$ENV{PATH}"
- )
+ set(LOG4CXX_DLL_DIR "$<SHELL_PATH:$<TARGET_FILE_DIR:log4cxx>>")
+ if(${testName} STREQUAL socketservertestcase)
+ set_tests_properties(socketservertestcase PROPERTIES
+ ENVIRONMENT "SOCKET_SERVER_COMMAND=$<JOIN:${START_SOCKET_SERVER_COMMAND}, >;PATH=${LOG4CXX_DLL_DIR}\;${APR_DLL_DIR}\;${APR_UTIL_DLL_DIR}"
+ )
+ else()
+ set_tests_properties(${testName} PROPERTIES
+ ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2;PATH==${LOG4CXX_DLL_DIR}\;${APR_DLL_DIR}\;${APR_UTIL_DLL_DIR}"
+ )
+ endif()
+ else()
+ if(${testName} STREQUAL socketservertestcase)
+ set_tests_properties(socketservertestcase PROPERTIES
+ ENVIRONMENT "SOCKET_SERVER_COMMAND=$<JOIN:${START_SOCKET_SERVER_COMMAND}, >"
+ )
+ else()
+ set_tests_properties(${testName} PROPERTIES
+ ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2"
+ )
+ endif()
endif()
endforeach()