Author: brane
Date: Mon Jun 30 08:31:43 2025
New Revision: 1926869
URL: http://svn.apache.org/viewvc?rev=1926869&view=rev
Log:
In the CMake build, make MockHTTPinC a separats static library and change
flags to use C99 and silence all warnings only for that target.
* test/CMakeLists.txt: Include the MockHTTPinC subdirectory and don't
fiddle with the CMAKE_C_FLAGS.
(TEST_ALL_SOURCES): Remove the MockHTTPinC source files.
(test_all): Depend on an link the mockhttpinc library.
* test/MockHTTPinC/CMakeLists.txt: New. Build the mockhttpinc library.
Added:
serf/trunk/test/MockHTTPinC/CMakeLists.txt (with props)
Modified:
serf/trunk/test/CMakeLists.txt
Modified: serf/trunk/test/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/serf/trunk/test/CMakeLists.txt?rev=1926869&r1=1926868&r2=1926869&view=diff
==============================================================================
--- serf/trunk/test/CMakeLists.txt (original)
+++ serf/trunk/test/CMakeLists.txt Mon Jun 30 08:31:43 2025
@@ -17,6 +17,7 @@
# under the License.
# ===================================================================
+add_subdirectory(MockHTTPinC)
set(TEST_ALL_SOURCES
"test_all.c"
@@ -30,8 +31,6 @@ set(TEST_ALL_SOURCES
"mock_buckets.c"
"mock_sock_buckets.c"
"test_ssl.c"
- "MockHTTPinC/MockHTTP.c"
- "MockHTTPinC/MockHTTP_server.c"
)
set(TEST_ALL_SUITES
@@ -52,11 +51,6 @@ set(SIMPLE_TEST_TARGETS
"serf_bwtp"
)
-if(CC_LIKE_GNUC)
- # MockHTTP requires C99 standard, so use it for the test suite.
- string(REPLACE "-std=c89" "-std=c99" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
-endif()
-
foreach(TEST_TARGET ${SIMPLE_TEST_TARGETS})
add_executable(${TEST_TARGET} "${TEST_TARGET}.c")
add_dependencies(${TEST_TARGET} serf_static)
@@ -64,10 +58,9 @@ foreach(TEST_TARGET ${SIMPLE_TEST_TARGET
endforeach()
add_executable(test_all ${TEST_ALL_SOURCES})
-add_dependencies(test_all serf_static)
-target_compile_definitions(test_all PRIVATE "-DMOCKHTTP_OPENSSL")
+add_dependencies(test_all serf_static mockhttpinc)
target_include_directories(test_all SYSTEM BEFORE PRIVATE
${SERF_DEPENDENCY_INCLUDES})
-target_link_libraries(test_all serf_static)
+target_link_libraries(test_all serf_static mockhttpinc)
file(GLOB RESPONSE_TEST_CASES
"${CMAKE_CURRENT_SOURCE_DIR}/testcases/*.response")
foreach(TEST_CASE ${RESPONSE_TEST_CASES})
Added: serf/trunk/test/MockHTTPinC/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/serf/trunk/test/MockHTTPinC/CMakeLists.txt?rev=1926869&view=auto
==============================================================================
--- serf/trunk/test/MockHTTPinC/CMakeLists.txt (added)
+++ serf/trunk/test/MockHTTPinC/CMakeLists.txt Mon Jun 30 08:31:43 2025
@@ -0,0 +1,52 @@
+# ===================================================================
+# 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.
+# ===================================================================
+
+set(MockHTTPinC_SOURCES
+ "MockHTTP.c"
+ "MockHTTP_server.c"
+)
+
+# Update compiler options for this library.
+if(CC_LIKE_GNUC)
+ # MockHTTP requires the C99 standard.
+ string(REPLACE "-std=c89" "-std=c99" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+ # Also silence all warnings.
+ if(NOT SHOW_MockHTTPinC_WARNINGS)
+ string(REGEX REPLACE " *-W[a-z][a-z-]+" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+ string(APPEND CMAKE_C_FLAGS " -w")
+ endif()
+elseif(MSVC)
+ # Silence warnings from Microsoft's compiler...
+ #
+ # ... of course, somewhere, somehow CMake adds the /W1 warning option
+ # to the command line and then MSVC complains that we're overriding /W1
+ # with /w. But it's more fun this way, or at least more #$@^&@%!
+ # Or maybe that's just MSBuild doing its magic, and it depends on the
+ # build generator. What would life be without its little mysteries?
+ if(NOT SHOW_MockHTTPinC_WARNINGS)
+ string(REGEX REPLACE " */(W|w[de])[0-9]+" "" CMAKE_C_FLAGS
${CMAKE_C_FLAGS})
+ string(APPEND CMAKE_C_FLAGS " /w")
+ endif()
+endif()
+mark_as_advanced(SHOW_MockHTTPinC_WARNINGS)
+
+add_library(mockhttpinc STATIC ${MockHTTPinC_SOURCES})
+target_compile_definitions(mockhttpinc PUBLIC "MOCKHTTP_OPENSSL")
+target_include_directories(mockhttpinc SYSTEM BEFORE
+ PRIVATE ${APR_INCLUDES} ${APRUTIL_INCLUDES})
Propchange: serf/trunk/test/MockHTTPinC/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native