You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2022/06/20 05:26:42 UTC

[logging-log4cxx] branch master updated: Prevent MSVC linker warning 4098 when building statically linked tests

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 5089ba23 Prevent MSVC linker warning 4098 when building statically linked tests
5089ba23 is described below

commit 5089ba2304d414877ecbd2e9364297d77557437a
Author: Stephen Webb <st...@sabreautonomous.com.au>
AuthorDate: Mon Jun 20 15:26:25 2022 +1000

    Prevent MSVC linker warning 4098 when building statically linked tests
---
 src/test/cpp/CMakeLists.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt
index 308eedf4..e2cb96d2 100644
--- a/src/test/cpp/CMakeLists.txt
+++ b/src/test/cpp/CMakeLists.txt
@@ -132,6 +132,13 @@ foreach(testName IN LISTS ALL_LOG4CXX_TESTS)
                 ENVIRONMENT "TOTO=wonderful;key1=value1;key2=value2;PATH=${ESCAPED_PATH}"
            )
         endif()
+        if(NOT BUILD_SHARED_LIBS)
+            # cmake selects a multi-threaded dynamically-linked runtime library by default
+            # (i.e. MSVC_RUNTIME_LIBRARY target property default value is "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
+            # APR static libraries specify the MSVC statically-linked runtime as the default library
+            # Use the MSVC statically-linked runtime to prevent the warning message 'LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs'
+            set_target_properties(${testName} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+        endif()
     else()
         if(${testName} STREQUAL socketservertestcase)
             set_tests_properties(socketservertestcase PROPERTIES