113498266Sopenharmony_ci#*************************************************************************** 213498266Sopenharmony_ci# _ _ ____ _ 313498266Sopenharmony_ci# Project ___| | | | _ \| | 413498266Sopenharmony_ci# / __| | | | |_) | | 513498266Sopenharmony_ci# | (__| |_| | _ <| |___ 613498266Sopenharmony_ci# \___|\___/|_| \_\_____| 713498266Sopenharmony_ci# 813498266Sopenharmony_ci# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 913498266Sopenharmony_ci# 1013498266Sopenharmony_ci# This software is licensed as described in the file COPYING, which 1113498266Sopenharmony_ci# you should have received as part of this distribution. The terms 1213498266Sopenharmony_ci# are also available at https://curl.se/docs/copyright.html. 1313498266Sopenharmony_ci# 1413498266Sopenharmony_ci# You may opt to use, copy, modify, merge, publish, distribute and/or sell 1513498266Sopenharmony_ci# copies of the Software, and permit persons to whom the Software is 1613498266Sopenharmony_ci# furnished to do so, under the terms of the COPYING file. 1713498266Sopenharmony_ci# 1813498266Sopenharmony_ci# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 1913498266Sopenharmony_ci# KIND, either express or implied. 2013498266Sopenharmony_ci# 2113498266Sopenharmony_ci# SPDX-License-Identifier: curl 2213498266Sopenharmony_ci# 2313498266Sopenharmony_ci########################################################################### 2413498266Sopenharmony_ciset(TARGET_LABEL_PREFIX "Test ") 2513498266Sopenharmony_ci 2613498266Sopenharmony_cifunction(setup_test TEST_NAME) # ARGN are the files in the test 2713498266Sopenharmony_ci 2813498266Sopenharmony_ci if(LIB_SELECTED STREQUAL LIB_STATIC) 2913498266Sopenharmony_ci # These are part of the libcurl static lib. Do not compile/link them again. 3013498266Sopenharmony_ci list(REMOVE_ITEM ARGN ${WARNLESS} ${MULTIBYTE} ${TIMEDIFF}) 3113498266Sopenharmony_ci endif() 3213498266Sopenharmony_ci 3313498266Sopenharmony_ci add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN}) 3413498266Sopenharmony_ci add_dependencies(testdeps ${TEST_NAME}) 3513498266Sopenharmony_ci string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME) 3613498266Sopenharmony_ci 3713498266Sopenharmony_ci include_directories( 3813498266Sopenharmony_ci ${CURL_SOURCE_DIR}/lib # To be able to reach "curl_setup_once.h" 3913498266Sopenharmony_ci ${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h" 4013498266Sopenharmony_ci ${CURL_BINARY_DIR}/include # To be able to reach "curl/curl.h" 4113498266Sopenharmony_ci ${CURL_SOURCE_DIR}/tests/libtest # To be able to build generated tests 4213498266Sopenharmony_ci ) 4313498266Sopenharmony_ci if(USE_ARES) 4413498266Sopenharmony_ci include_directories(${CARES_INCLUDE_DIR}) 4513498266Sopenharmony_ci endif() 4613498266Sopenharmony_ci 4713498266Sopenharmony_ci target_link_libraries(${TEST_NAME} ${LIB_SELECTED} ${CURL_LIBS}) 4813498266Sopenharmony_ci 4913498266Sopenharmony_ci set_target_properties(${TEST_NAME} 5013498266Sopenharmony_ci PROPERTIES COMPILE_DEFINITIONS ${UPPER_TEST_NAME}) 5113498266Sopenharmony_ci set_target_properties(${TEST_NAME} 5213498266Sopenharmony_ci PROPERTIES PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}") 5313498266Sopenharmony_ciendfunction() 5413498266Sopenharmony_ci 5513498266Sopenharmony_ci 5613498266Sopenharmony_citransform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") 5713498266Sopenharmony_ciinclude(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) 5813498266Sopenharmony_ci 5913498266Sopenharmony_ciforeach(TEST_NAME ${noinst_PROGRAMS}) 6013498266Sopenharmony_ci if(DEFINED ${TEST_NAME}_SOURCES) 6113498266Sopenharmony_ci setup_test(${TEST_NAME} ${${TEST_NAME}_SOURCES}) 6213498266Sopenharmony_ci else() 6313498266Sopenharmony_ci setup_test(${TEST_NAME} ${nodist_${TEST_NAME}_SOURCES}) 6413498266Sopenharmony_ci endif() 6513498266Sopenharmony_ciendforeach() 6613498266Sopenharmony_ci 6713498266Sopenharmony_ci# Allows for hostname override to make tests machine independent. 6813498266Sopenharmony_ci# TODO this cmake build assumes a shared build, detect static linking here! 6913498266Sopenharmony_ciif(NOT WIN32) 7013498266Sopenharmony_ci add_library(hostname MODULE EXCLUDE_FROM_ALL sethostname.c) 7113498266Sopenharmony_ci add_dependencies(testdeps hostname) 7213498266Sopenharmony_ci # Output to .libs for compatibility with autotools, the test data expects a 7313498266Sopenharmony_ci # library at (tests)/libtest/.libs/libhostname.so 7413498266Sopenharmony_ci set_target_properties(hostname PROPERTIES 7513498266Sopenharmony_ci LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.libs) 7613498266Sopenharmony_ci if(HIDES_CURL_PRIVATE_SYMBOLS) 7713498266Sopenharmony_ci set_property(TARGET hostname APPEND PROPERTY COMPILE_DEFINITIONS "CURL_HIDDEN_SYMBOLS") 7813498266Sopenharmony_ci set_property(TARGET hostname APPEND PROPERTY COMPILE_FLAGS ${CURL_CFLAG_SYMBOLS_HIDE}) 7913498266Sopenharmony_ci endif() 8013498266Sopenharmony_ciendif() 8113498266Sopenharmony_ci 8213498266Sopenharmony_ciadd_custom_command( 8313498266Sopenharmony_ci OUTPUT lib1521.c 8413498266Sopenharmony_ci COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl < ${CURL_SOURCE_DIR}/include/curl/curl.h > lib1521.c 8513498266Sopenharmony_ci DEPENDS 8613498266Sopenharmony_ci "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl" 8713498266Sopenharmony_ci "${CURL_SOURCE_DIR}/include/curl/curl.h" 8813498266Sopenharmony_ci VERBATIM) 89