 +else()
 +  find_package(EXPAT)
 +endif()
-+if(EXPAT_FOUND)
-+  include_directories(${EXPAT_INCLUDE_DIRS})
-+else()
++if(NOT EXPAT_FOUND)
 +  message(FATAL_ERROR "can't find expat - libstrophe cmake currently hard-coded to use expat")
 +endif()
++####################
++include(CheckLibraryExists)
++function(checkLibraryConcat lib symbol liblist)
++  string(TOUPPER ${lib} LIB)
++  check_library_exists("${lib}" "${symbol}" "" LIBSTROPHE_HAS_${LIB})
++  if(LIBSTROPHE_HAS_${LIB})
++    list(APPEND ${liblist} ${lib})
++    set(${liblist} ${${liblist}} PARENT_SCOPE)
++  endif()
++endfunction()
++checkLibraryConcat(resolv __res_query SYS_LIBS)
 +########################################
 +# version
 +set(verString "^AC_INIT.*\\[\([.0-9]*\)\\].*")

+  sock.c
+  sock.h
+  stanza.c
+  tls_dummy.c
+  #tls_gnutls.c # tls_openssl instead
+  tls.h
+  tls_openssl.c

+install(EXPORT ${targetsFile} DESTINATION lib/cmake)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..5bf5a5f
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,28 @@
+add_library(testlib STATIC test.c test.h)
+target_link_libraries(testlib libstrophe)
+set_property(TARGET testlib PROPERTY FOLDER tests)
+set(tests
+  check_parser
