2020-03-23 21:44:29 +08:00
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2023-01-02 20:51:48 +08:00
|
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
|
|
#
|
|
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
# KIND, either express or implied.
|
|
|
|
#
|
2016-09-04 18:37:46 +08:00
|
|
|
# SPDX-License-Identifier: curl
|
2022-05-17 17:16:50 +08:00
|
|
|
#
|
2020-03-23 21:44:29 +08:00
|
|
|
###########################################################################
|
2009-06-10 01:29:16 +08:00
|
|
|
set(TARGET_LABEL_PREFIX "Test ")
|
2009-04-07 05:05:44 +08:00
|
|
|
|
2018-07-17 14:36:59 +08:00
|
|
|
function(setup_test TEST_NAME) # ARGN are the files in the test
|
2023-05-09 18:10:40 +08:00
|
|
|
|
2023-06-22 17:24:37 +08:00
|
|
|
if(LIB_SELECTED STREQUAL LIB_STATIC)
|
2023-05-09 18:10:40 +08:00
|
|
|
# These are part of the libcurl static lib. Do not compile/link them again.
|
|
|
|
list(REMOVE_ITEM ARGN ${WARNLESS} ${MULTIBYTE} ${TIMEDIFF})
|
|
|
|
endif()
|
|
|
|
|
2020-05-10 08:10:20 +08:00
|
|
|
add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
|
|
|
|
add_dependencies(testdeps ${TEST_NAME})
|
2009-06-10 01:29:16 +08:00
|
|
|
string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)
|
2009-04-07 05:05:44 +08:00
|
|
|
|
2009-06-10 01:29:16 +08:00
|
|
|
include_directories(
|
2013-01-07 02:06:49 +08:00
|
|
|
${CURL_SOURCE_DIR}/lib # To be able to reach "curl_setup_once.h"
|
2009-07-14 21:25:14 +08:00
|
|
|
${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
|
2017-05-22 15:05:10 +08:00
|
|
|
${CURL_BINARY_DIR}/include # To be able to reach "curl/curl.h"
|
2017-06-27 23:27:22 +08:00
|
|
|
${CURL_SOURCE_DIR}/tests/libtest # To be able to build generated tests
|
2009-06-10 01:29:16 +08:00
|
|
|
)
|
2014-11-06 08:32:45 +08:00
|
|
|
if(USE_ARES)
|
2009-07-15 03:03:31 +08:00
|
|
|
include_directories(${CARES_INCLUDE_DIR})
|
|
|
|
endif()
|
2014-08-22 23:02:59 +08:00
|
|
|
|
2023-06-22 17:24:37 +08:00
|
|
|
target_link_libraries(${TEST_NAME} ${LIB_SELECTED} ${CURL_LIBS})
|
2009-04-07 05:05:44 +08:00
|
|
|
|
2009-06-10 01:29:16 +08:00
|
|
|
set_target_properties(${TEST_NAME}
|
|
|
|
PROPERTIES COMPILE_DEFINITIONS ${UPPER_TEST_NAME})
|
|
|
|
set_target_properties(${TEST_NAME}
|
|
|
|
PROPERTIES PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}")
|
|
|
|
endfunction()
|
2009-04-07 05:05:44 +08:00
|
|
|
|
|
|
|
|
2009-06-10 01:29:16 +08:00
|
|
|
transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
|
|
|
include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
|
2009-04-07 05:05:44 +08:00
|
|
|
|
2009-06-10 01:29:16 +08:00
|
|
|
foreach(TEST_NAME ${noinst_PROGRAMS})
|
2018-06-05 02:28:59 +08:00
|
|
|
if(DEFINED ${TEST_NAME}_SOURCES)
|
|
|
|
setup_test(${TEST_NAME} ${${TEST_NAME}_SOURCES})
|
|
|
|
else()
|
|
|
|
setup_test(${TEST_NAME} ${nodist_${TEST_NAME}_SOURCES})
|
|
|
|
endif()
|
2009-06-10 01:29:16 +08:00
|
|
|
endforeach()
|
2009-04-07 05:05:44 +08:00
|
|
|
|
2014-11-06 08:32:44 +08:00
|
|
|
# Allows for hostname override to make tests machine independent.
|
|
|
|
# TODO this cmake build assumes a shared build, detect static linking here!
|
|
|
|
if(NOT WIN32)
|
build: add more picky warnings and fix them
Enable more picky compiler warnings. I've found these options in the
nghttp3 project when implementing the CMake quick picky warning
functionality for it [1].
`-Wunused-macros` was too noisy to keep around, but fixed a few issues
it revealed while testing.
- autotools: reflect the more precisely-versioned clang warnings.
Follow-up to 033f8e2a08eb1d3102f08c4d8c8e85470f8b460e #12324
- autotools: sync between clang and gcc the way we set `no-multichar`.
- autotools: avoid setting `-Wstrict-aliasing=3` twice.
- autotools: disable `-Wmissing-noreturn` for MSYS gcc targets [2].
It triggers in libtool-generated stub code.
- lib/timeval: delete a redundant `!MSDOS` guard from a `WIN32` branch.
- lib/curl_setup.h: delete duplicate declaration for `fileno`.
Added in initial commit ae1912cb0d494b48d514d937826c9fe83ec96c4d
(1999-12-29). This suggests this may not be needed anymore, but if
it does, we may restore this for those specific (non-Windows) systems.
- lib: delete unused macro `FTP_BUFFER_ALLOCSIZE` since
c1d6fe2aaa5a26e49a69a4f2495b3cc7a24d9394.
- lib: delete unused macro `isxdigit_ascii` since
f65f750742068f579f4ee6d8539ed9d5f0afcb85.
- lib/mqtt: delete unused macro `MQTT_HEADER_LEN`.
- lib/multi: delete unused macro `SH_READ`/`SH_WRITE`.
- lib/hostip: add `noreturn` function attribute via new `CURL_NORETURN`
macro.
- lib/mprintf: delete duplicate declaration for `Curl_dyn_vprintf`.
- lib/rand: fix `-Wunreachable-code` and related fallouts [3].
- lib/setopt: fix `-Wunreachable-code-break`.
- lib/system_win32 and lib/timeval: fix double declarations for
`Curl_freq` and `Curl_isVistaOrGreater` in CMake UNITY mode [4].
- lib/warnless: fix double declarations in CMake UNITY mode [5].
This was due to force-disabling the header guard of `warnless.h` to
to reapply it to source code coming after `warnless.c` in UNITY
builds. This reapplied declarations too, causing the warnings.
Solved by adding a header guard for the lines that actually need
to be reapplied.
- lib/vauth/digest: fix `-Wunreachable-code-break` [6].
- lib/vssh/libssh2: fix `-Wunreachable-code-break` and delete redundant
block.
- lib/vtls/sectransp: fix `-Wunreachable-code-break` [7].
- lib/vtls/sectransp: suppress `-Wunreachable-code`.
Detected in `else` branches of dynamic feature checks, with results
known at compile-time, e.g.
```c
if(SecCertificateCopySubjectSummary) /* -> true */
```
Likely fixable as a separate micro-project, but given SecureTransport
is deprecated anyway, let's just silence these locally.
- src/tool_help: delete duplicate declaration for `helptext`.
- src/tool_xattr: fix `-Wunreachable-code`.
- tests: delete duplicate declaration for `unitfail` [8].
- tests: delete duplicate declaration for `strncasecompare`.
- tests/libtest: delete duplicate declaration for `gethostname`.
Originally added in 687df5c8c39c370a59999b9afc0917d808d978b7
(2010-08-02).
Got complicated later: c49e9683b85ba9d12cbb6eebc4ab2c8dba68fbdc
If there are still systems around with warnings, we may restore the
prototype, but limited for those systems.
- tests/lib2305: delete duplicate declaration for
`libtest_debug_config`.
- tests/h2-download: fix `-Wunreachable-code-break`.
[1] https://github.com/ngtcp2/nghttp3/blob/a70edb08e954d690e8fb2c1df999b5a056f8bf9f/cmake/PickyWarningsC.cmake
[2] https://ci.appveyor.com/project/curlorg/curl/builds/48553586/job/3qkgjauiqla5fj45?fullLog=true#L1675
[3] https://github.com/curl/curl/actions/runs/6880886309/job/18716044703?pr=12331#step:7:72
https://github.com/curl/curl/actions/runs/6883016087/job/18722707368?pr=12331#step:7:109
[4] https://ci.appveyor.com/project/curlorg/curl/builds/48555101/job/9g15qkrriklpf1ut#L204
[5] https://ci.appveyor.com/project/curlorg/curl/builds/48555101/job/9g15qkrriklpf1ut#L218
[6] https://github.com/curl/curl/actions/runs/6880886309/job/18716042927?pr=12331#step:7:290
[7] https://github.com/curl/curl/actions/runs/6891484996/job/18746659406?pr=12331#step:9:1193
[8] https://github.com/curl/curl/actions/runs/6882803986/job/18722082562?pr=12331#step:33:1870
Closes #12331
2023-11-15 22:43:36 +08:00
|
|
|
add_library(hostname MODULE EXCLUDE_FROM_ALL sethostname.c)
|
2020-05-10 08:10:20 +08:00
|
|
|
add_dependencies(testdeps hostname)
|
2014-11-06 08:32:44 +08:00
|
|
|
# Output to .libs for compatibility with autotools, the test data expects a
|
|
|
|
# library at (tests)/libtest/.libs/libhostname.so
|
|
|
|
set_target_properties(hostname PROPERTIES
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.libs)
|
2016-09-04 18:37:46 +08:00
|
|
|
if(HIDES_CURL_PRIVATE_SYMBOLS)
|
|
|
|
set_property(TARGET hostname APPEND PROPERTY COMPILE_DEFINITIONS "CURL_HIDDEN_SYMBOLS")
|
|
|
|
set_property(TARGET hostname APPEND PROPERTY COMPILE_FLAGS ${CURL_CFLAG_SYMBOLS_HIDE})
|
|
|
|
endif()
|
2014-11-06 08:32:44 +08:00
|
|
|
endif()
|
2009-04-08 05:59:15 +08:00
|
|
|
|
2017-06-27 23:27:22 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT lib1521.c
|
2018-09-07 21:45:11 +08:00
|
|
|
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl < ${CURL_SOURCE_DIR}/include/curl/curl.h > lib1521.c
|
2017-06-27 23:27:22 +08:00
|
|
|
DEPENDS
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl"
|
2018-09-07 21:45:11 +08:00
|
|
|
"${CURL_SOURCE_DIR}/include/curl/curl.h"
|
2017-06-27 23:27:22 +08:00
|
|
|
VERBATIM)
|