1#*************************************************************************** 2# _ _ ____ _ 3# Project ___| | | | _ \| | 4# / __| | | | |_) | | 5# | (__| |_| | _ <| |___ 6# \___|\___/|_| \_\_____| 7# 8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 9# 10# This software is licensed as described in the file COPYING, which 11# you should have received as part of this distribution. The terms 12# are also available at https://curl.se/docs/copyright.html. 13# 14# You may opt to use, copy, modify, merge, publish, distribute and/or sell 15# copies of the Software, and permit persons to whom the Software is 16# furnished to do so, under the terms of the COPYING file. 17# 18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19# KIND, either express or implied. 20# 21# SPDX-License-Identifier: curl 22# 23########################################################################### 24 25# Get 'LIBTESTPROGS', '*_SOURCES', 'TESTUTIL', 'TSTTRACE', 'WARNLESS', 'MULTIBYTE', 'TIMEDIFF', 'THREADS', 'FIRSTFILES' variables 26transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") 27include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") 28 29set_source_files_properties("../../lib/curl_multibyte.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) 30 31add_custom_command( 32 OUTPUT "lib1521.c" 33 COMMAND ${PERL_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl" < "${PROJECT_SOURCE_DIR}/include/curl/curl.h" "lib1521.c" 34 DEPENDS 35 "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl" 36 "${PROJECT_SOURCE_DIR}/include/curl/curl.h" 37 VERBATIM) 38 39if(CURL_TEST_BUNDLES) 40 add_custom_command( 41 OUTPUT "libtest_bundle.c" 42 COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tests/mk-bundle.pl" "${CMAKE_CURRENT_SOURCE_DIR}" > "libtest_bundle.c" 43 DEPENDS 44 "${PROJECT_SOURCE_DIR}/tests/mk-bundle.pl" ${FIRSTFILES} "lib1521.c" 45 "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc" 46 VERBATIM) 47 48 set(LIBTESTPROGS "libtests") 49 set(libtests_SOURCES "libtest_bundle.c") 50 list(APPEND libtests_SOURCES ${TESTUTIL} ${TSTTRACE}) 51 if(LIB_SELECTED STREQUAL LIB_SHARED) 52 # These are part of the libcurl static lib. Add them here when linking shared. 53 list(APPEND libtests_SOURCES ${WARNLESS} ${MULTIBYTE} ${TIMEDIFF} ${THREADS}) 54 endif() 55endif() 56 57foreach(_target IN LISTS LIBTESTPROGS) 58 if(DEFINED ${_target}_SOURCES) 59 set(_sources ${${_target}_SOURCES}) 60 else() 61 set(_sources ${nodist_${_target}_SOURCES}) 62 endif() 63 64 if(LIB_SELECTED STREQUAL LIB_STATIC) 65 # These are part of the libcurl static lib. Do not compile/link them again. 66 list(REMOVE_ITEM _sources ${WARNLESS} ${MULTIBYTE} ${TIMEDIFF} ${THREADS}) 67 endif() 68 69 string(TOUPPER ${_target} _upper_target) 70 set(_target_name "${_target}") 71 add_executable(${_target_name} EXCLUDE_FROM_ALL ${_sources}) 72 add_dependencies(testdeps ${_target_name}) 73 target_link_libraries(${_target_name} ${LIB_SELECTED} ${CURL_LIBS}) 74 target_include_directories(${_target_name} PRIVATE 75 "${PROJECT_BINARY_DIR}/lib" # for "curl_config.h" 76 "${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h" 77 "${PROJECT_SOURCE_DIR}/tests/libtest" # to be able to build generated tests 78 ) 79 if(NOT CURL_TEST_BUNDLES) 80 set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS ${_upper_target}) 81 endif() 82 set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_GETADDRINFO_OVERRIDE") 83 set_target_properties(${_target_name} PROPERTIES 84 OUTPUT_NAME "${_target}" 85 PROJECT_LABEL "Test libtest ${_target}") 86endforeach() 87