Enable cmake tests for AppVeyor (#313)

Tests require linking against the static library on Windows otherwise the symbols are not exported for internals being tested.

Fix By: Brad House (@bradh352)
pull/315/head
Brad House 5 years ago committed by GitHub
parent f3d9d7f55f
commit 3cd3c19558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      CMakeLists.txt
  2. 26
      appveyor.yml
  3. 2
      test/CMakeLists.txt

@ -37,6 +37,12 @@ OPTION (CARES_BUILD_TESTS "Build and run tests"
OPTION (CARES_BUILD_CONTAINER_TESTS "Build and run container tests (implies CARES_BUILD_TESTS, Linux only)" OFF)
OPTION (CARES_BUILD_TOOLS "Build tools" ON)
# Tests require static to be enabled
IF (CARES_BUILD_TESTS)
SET (CARES_STATIC ON)
SET (CARES_STATIC_PIC ON)
ENDIF ()
# allow linking against the static runtime library in msvc
IF (MSVC)
OPTION (CARES_MSVC_STATIC_RUNTIME "Link against the static runtime library" OFF)
@ -641,8 +647,10 @@ IF (CARES_STATIC)
ADD_LIBRARY (${LIBNAME} STATIC ${CSOURCES})
SET_TARGET_PROPERTIES (${LIBNAME} PROPERTIES
EXPORT_NAME cares${STATIC_SUFFIX}
OUTPUT_NAME cares${STATIC_SUFFIX}
EXPORT_NAME cares${STATIC_SUFFIX}
OUTPUT_NAME cares${STATIC_SUFFIX}
COMPILE_PDB_NAME cares${STATIC_SUFFIX}
COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
IF (CARES_STATIC_PIC)
@ -662,6 +670,11 @@ IF (CARES_STATIC)
INSTALL (TARGETS ${LIBNAME} EXPORT ${PROJECT_NAME}-targets COMPONENT Devel
${TARGETS_INST_DEST}
)
INSTALL(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cares${STATIC_SUFFIX}.pdb
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Library
OPTIONAL
)
ENDIF ()
# For chain building: add alias targets that look like import libs that would be returned by find_package(c-ares).

@ -65,22 +65,7 @@ build_script:
- if "%BUILDTOOL%" == "NMAKE" nmake /NOLOGO /f .\Makefile.msvc
- if "%BUILDTOOL%" == "CMAKE" mkdir C:\projects\build-cares
- if "%BUILDTOOL%" == "CMAKE" cd C:\projects\build-cares
- if "%BUILDTOOL%" == "CMAKE" cmake -GNinja -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=C:\projects\build-cares\test_install %CMAKE_EXTRA_OPTIONS% %APPVEYOR_BUILD_FOLDER%
# -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_BUILD_TESTS=ON
# Note: Tests currently fail to compile due to ares-test-internal.cc needing access to :
# _aresx_sltosi
# _aresx_sztoui
# _ares_inet_net_pton
# _ares_malloc_data
# _ares_strdup
# _ares_writev
# _ares__is_onion_domain
# _ares__get_hostent
# _ares__read_line
# _ares__readaddrinfo
# _ares__bitncmp
# _ares_malloc
# _ares_free
- if "%BUILDTOOL%" == "CMAKE" cmake -GNinja -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_INSTALL_PREFIX=C:\projects\build-cares\test_install -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_BUILD_TESTS=ON %CMAKE_EXTRA_OPTIONS% %APPVEYOR_BUILD_FOLDER%
- if "%BUILDTOOL%" == "CMAKE" ninja install
- if "%BUILDTOOL%" == "MAKE" copy ares_build.h.dist ares_build.h
- if "%BUILDTOOL%" == "MAKE" mingw32-make.exe -f Makefile.m32 demos
@ -99,10 +84,11 @@ test_script:
- if "%BUILDTOOL%" == "CMAKE" .\adig.exe www.google.com
- if "%BUILDTOOL%" == "CMAKE" .\acountry.exe www.google.com
- if "%BUILDTOOL%" == "CMAKE" .\ahost.exe www.google.com
# - if "%BUILDTOOL%" == "CMAKE" .\arestest.exe -4 -v
# - if "%BUILDTOOL%" == "CMAKE" .\aresfuzz.exe "$env:APPVEYOR_BUILD_FOLDER\test\fuzzinput\*"
# - if "%BUILDTOOL%" == "CMAKE" .\aresfuzzname.exe "$env:APPVEYOR_BUILD_FOLDER\test\fuzznames\*"
# - if "%BUILDTOOL%" == "CMAKE" .\dnsdump.exe "$env:APPVEYOR_BUILD_FOLDER\test\fuzzinput\answer_a" "$env:APPVEYOR_BUILD_FOLDER\test\fuzzinput\answer_aaaa"
- if "%BUILDTOOL%" == "CMAKE" .\arestest.exe -4 -v
# Windows cant do shell expansion
# - if "%BUILDTOOL%" == "CMAKE" .\aresfuzz.exe %APPVEYOR_BUILD_FOLDER%\test\fuzzinput\*
# - if "%BUILDTOOL%" == "CMAKE" .\aresfuzzname.exe %APPVEYOR_BUILD_FOLDER%\test\fuzznames\*
- if "%BUILDTOOL%" == "CMAKE" .\dnsdump.exe "%APPVEYOR_BUILD_FOLDER%\test\fuzzinput\answer_a" "%APPVEYOR_BUILD_FOLDER%\test\fuzzinput\answer_aaaa"
#on_finish:
# - cd C:\projects\build-cares\test

@ -11,7 +11,7 @@ set(ARES_SRC_DIR ${c-ares_SOURCE_DIR})
add_library(caresinternal INTERFACE)
target_compile_definitions(caresinternal INTERFACE HAVE_CONFIG_H=1)
target_include_directories(caresinternal INTERFACE ${ARES_SRC_DIR})
target_link_libraries(caresinternal INTERFACE ${PROJECT_NAME})
target_link_libraries(caresinternal INTERFACE ${PROJECT_NAME}::cares_static)
# Google Test and Mock
set(GMOCK_DIR gmock-1.8.0)

Loading…
Cancel
Save