CMakeLists.txt (2426B)
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 BUNDLE, FIRST_C, FIRST_H, CURLX_C, TESTS_C variables 26 curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") 27 include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") 28 29 if(LIB_SELECTED STREQUAL LIB_STATIC) 30 set(CURLX_C "") # Already exported from the libcurl static build. Skip them. 31 endif() 32 33 add_custom_command(OUTPUT "${BUNDLE}.c" 34 COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" 35 --include ${CURLX_C} --test ${TESTS_C} > "${BUNDLE}.c" 36 DEPENDS 37 "${PROJECT_SOURCE_DIR}/scripts/mk-unity.pl" "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc" 38 ${FIRST_C} ${CURLX_C} ${TESTS_C} 39 VERBATIM) 40 41 add_executable(${BUNDLE} EXCLUDE_FROM_ALL "${BUNDLE}.c") 42 add_dependencies(testdeps ${BUNDLE}) 43 target_link_libraries(${BUNDLE} ${LIB_SELECTED} ${CURL_LIBS}) 44 target_include_directories(${BUNDLE} PRIVATE 45 "${PROJECT_BINARY_DIR}/lib" # for "curl_config.h" 46 "${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h", curlx 47 "${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources 48 ) 49 set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_OLDIES") 50 set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "") 51 52 curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${TESTS_C})