# Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT # Get rid of: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc IF (MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") ENDIF () find_package(Threads) find_package(GTest REQUIRED) IF (NOT TARGET GTest::gmock) Message(FATAL_ERROR "GoogleTest found but the GMock component was not found") ENDIF() # create target to access and use internal cares library add_library(caresinternal INTERFACE) target_compile_definitions(caresinternal INTERFACE HAVE_CONFIG_H=1) target_include_directories(caresinternal INTERFACE "${PROJECT_BINARY_DIR}" "${PROJECT_BINARY_DIR}/src/lib" "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/src/lib" "${PROJECT_SOURCE_DIR}/include" ) IF (CARES_STATIC) target_link_libraries(caresinternal INTERFACE ${PROJECT_NAME}::cares_static) ELSE () target_link_libraries(caresinternal INTERFACE ${PROJECT_NAME}::cares) ENDIF () transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) add_executable(arestest ${TESTSOURCES} ${TESTHEADERS}) target_include_directories(arestest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(arestest PRIVATE caresinternal GTest::gmock) IF (CARES_BUILD_CONTAINER_TESTS) target_compile_definitions(arestest PRIVATE HAVE_USER_NAMESPACE HAVE_UTS_NAMESPACE) ENDIF () add_executable(aresfuzz ${FUZZSOURCES}) target_link_libraries(aresfuzz PRIVATE caresinternal) add_executable(aresfuzzname ${FUZZNAMESOURCES}) target_link_libraries(aresfuzzname PRIVATE caresinternal) add_executable(dnsdump ${DUMPSOURCES}) target_link_libraries(dnsdump PRIVATE caresinternal) # register tests add_test(NAME arestest COMMAND $) file(GLOB_RECURSE FUZZINPUT_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/fuzzinput" "fuzzinput/*") add_test( NAME aresfuzz WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/fuzzinput" COMMAND $ ${FUZZINPUT_FILES} ) file(GLOB_RECURSE FUZZNAMES_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/fuzznames" "fuzznames/*") add_test( NAME aresfuzzname WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/fuzznames" COMMAND $ ${FUZZNAMES_FILES} )