<commit_before>diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..80ca3f8
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,57 @@
+cmake_minimum_required(VERSION 3.0)
+project(libstrophe)
+include(flags OPTIONAL)
+enable_testing()
+set_property(GLOBAL PROPERTY USE_FOLDERS ON) # enables MSVC Solution Folders
+########################################
+if(MSVC)
+  add_definitions(
+    -D_CRT_NONSTDC_NO_DEPRECATE
+    -D_CRT_SECURE_NO_WARNINGS
+    -D_WINSOCK_DEPRECATED_NO_WARNINGS
+    )
+endif()
+########################################
+option(CMAKE_USE_OPENSSL_MODULE_PATH "Find OpenSSL in CMAKE_MODULE_PATH." OFF)
+mark_as_advanced(CMAKE_USE_OPENSSL_MODULE_PATH)
+if(CMAKE_USE_OPENSSL_MODULE_PATH)
+  find_package(usexp-OpenSSL REQUIRED PATHS ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH)
+else()
+  find_package(OpenSSL)
+endif()
+if(OPENSSL_FOUND)
+  include_directories(${OPENSSL_INCLUDE_DIR})
+else()
+  message(FATAL_ERROR "can't find OpenSSL - libstrophe cmake currently hard-coded to use OpenSSL")
+endif()
+####################
+option(CMAKE_USE_EXPAT_MODULE_PATH "Find expat in CMAKE_MODULE_PATH." OFF)
+mark_as_advanced(CMAKE_USE_EXPAT_MODULE_PATH)
+if(CMAKE_USE_EXPAT_MODULE_PATH)
+  find_package(usexp-EXPAT REQUIRED PATHS ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH)
+else()
+  find_package(EXPAT)
+endif()
+if(EXPAT_FOUND)
+  include_directories(${EXPAT_INCLUDE_DIRS})
+else()
+  message(FATAL_ERROR "can't find expat - libstrophe cmake currently hard-coded to use expat")
+endif()
+########################################
+# version
+set(verString "^AC_INIT.*\\[\([.0-9]*\)\\].*")
+set(verFile configure.ac)
+file(STRINGS ${verFile} VER REGEX "${verString}")
+string(REGEX REPLACE "${verString}" "\\1" VER ${VER})
+if(NOT DEFINED LIBSTROPHE_VER)
+  set(LIBSTROPHE_VER ${VER})
+elseif(NOT ${LIBSTROPHE_VER} STREQUAL ${VER})
+  message(AUTHOR_WARNING "version passed in (${LIBSTROPHE_VER}) doesn't match version from ${verFile} (${VER})")
+endif()
+set(ver _${LIBSTROPHE_VER})
+set(verDir /${PROJECT_NAME}${ver})
+########################################
+add_subdirectory(src)
+add_subdirectory(examples)
+add_subdirectory(tests)
+install(FILES strophe.h DESTINATION include${verDir}/${PROJECT_NAME})
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 0000000..b70b0df
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(examples
+  active
+  basic
+  bot
+  component
+  roster
+  uuid
+  )
+foreach(exe ${examples})
+  add_executable(${exe} ${exe}.c)
+  target_link_libraries(${exe} libstrophe resolv) # TODO library dependencies
+  set_property(TARGET ${exe} PROPERTY FOLDER examples)
+endforeach()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..e3c4db9
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,65 @@
+set(lib_name ${PROJECT_NAME})
+########################################
+# source
+set(${lib_name}_libsrcs
+  auth.c
+  common.h
+  conn.c
+  crypto.c
+  ctx.c
+  event.c
+  handler.c
+  hash.c
+  hash.h
+  jid.c
+  md5.c
+  md5.h
+  ostypes.h
+  parser_expat.c
+  parser.h
+  #parser_libxml2.c # parser_expat instead
+  rand.c
+  rand.h
+  resolver.c
+  resolver.h
+  sasl.c
+  sasl.h
+  scram.c
+  scram.h
+  sha1.c
+  sha1.h
+  snprintf.c
+  snprintf.h
+  sock.c
+  sock.h
+  stanza.c
+  tls_dummy.c
+  #tls_gnutls.c # tls_openssl instead
+  tls.h
+  tls_openssl.c
+  #tls_schannel.c # tls_openssl instead
+  util.c
+  util.h
+  uuid.c
+  )
+source_group("" FILES ${${lib_name}_libsrcs})
+########################################
+# library
+add_library(${lib_name} STATIC ${${lib_name}_libsrcs})
+target_link_libraries(${lib_name} ${EXPAT_LIBRARIES} ${OPENSSL_LIBRARIES})
+target_include_directories(${lib_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
+  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+  )
+set_target_properties(${lib_name} PROPERTIES
+  OUTPUT_NAME ${lib_name}${ver}
+  PREFIX "" # strip off the "lib" prefix, since it's already libstrophe
+  )
+########################################
+# install
+set(targetsFile ${PROJECT_NAME}${ver}-targets)
+install(TARGETS ${lib_name} EXPORT ${targetsFile}
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  ARCHIVE DESTINATION lib
+  )
+install(EXPORT ${targetsFile} DESTINATION lib/cmake)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..75e8a7c
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,28 @@
+add_library(testlib STATIC test.c test.h)
+target_link_libraries(testlib libstrophe resolv) # TODO library dependencies
+set_property(TARGET testlib PROPERTY FOLDER tests)
+set(tests
+  check_parser
+  res_query_dump
+  test_base64
+  test_ctx
+  test_hash
+  test_jid
+  test_md5
+  test_rand
+  test_resolver
+  test_sasl
+  test_scram
+  test_sha1
+  test_snprintf
+  test_sock
+  test_string
+  )
+foreach(exe ${tests})
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${exe}.c) # there are some tests only in repo, not in download
+    add_executable(${exe} ${exe}.c)
+    target_link_libraries(${exe} testlib)
+    add_test(NAME ${exe} COMMAND ${exe})
+    set_property(TARGET ${exe} PROPERTY FOLDER tests)
+  endif()
+endforeach()<commit_msg>libstrophe patch: depends on resolv on some platforms<commit_after>diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..eeab699
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,64 @@
+cmake_minimum_required(VERSION 3.0)
+project(libstrophe)
+include(flags OPTIONAL)
+enable_testing()
+set_property(GLOBAL PROPERTY USE_FOLDERS ON) # enables MSVC Solution Folders
+########################################
+if(MSVC)
+  add_definitions(
+    -D_CRT_NONSTDC_NO_DEPRECATE
+    -D_CRT_SECURE_NO_WARNINGS
+    -D_WINSOCK_DEPRECATED_NO_WARNINGS
+    )
+endif()
+########################################
+option(CMAKE_USE_OPENSSL_MODULE_PATH "Find OpenSSL in CMAKE_MODULE_PATH." OFF)
+mark_as_advanced(CMAKE_USE_OPENSSL_MODULE_PATH)
+if(CMAKE_USE_OPENSSL_MODULE_PATH)
+  find_package(usexp-OpenSSL REQUIRED PATHS ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH)
+else()
+  find_package(OpenSSL)
+endif()
+if(NOT OPENSSL_FOUND)
+  message(FATAL_ERROR "can't find OpenSSL - libstrophe cmake currently hard-coded to use OpenSSL")
+endif()
+####################
+option(CMAKE_USE_EXPAT_MODULE_PATH "Find expat in CMAKE_MODULE_PATH." OFF)
+mark_as_advanced(CMAKE_USE_EXPAT_MODULE_PATH)
+if(CMAKE_USE_EXPAT_MODULE_PATH)
+  find_package(usexp-EXPAT REQUIRED PATHS ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH)
+else()
+  find_package(EXPAT)
+endif()
+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]*\)\\].*")
+set(verFile configure.ac)
+file(STRINGS ${verFile} VER REGEX "${verString}")
+string(REGEX REPLACE "${verString}" "\\1" VER ${VER})
+if(NOT DEFINED LIBSTROPHE_VER)
+  set(LIBSTROPHE_VER ${VER})
+elseif(NOT ${LIBSTROPHE_VER} STREQUAL ${VER})
+  message(AUTHOR_WARNING "version passed in (${LIBSTROPHE_VER}) doesn't match version from ${verFile} (${VER})")
+endif()
+set(ver _${LIBSTROPHE_VER})
+set(verDir /${PROJECT_NAME}${ver})
+########################################
+add_subdirectory(src)
+add_subdirectory(examples)
+add_subdirectory(tests)
+install(FILES strophe.h DESTINATION include${verDir}/${PROJECT_NAME})
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 0000000..3706f2e
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(examples
+  active
+  basic
+  bot
+  component
+  roster
+  uuid
+  )
+foreach(exe ${examples})
+  add_executable(${exe} ${exe}.c)
+  target_link_libraries(${exe} libstrophe)
+  set_property(TARGET ${exe} PROPERTY FOLDER examples)
+endforeach()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..c44e631
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,68 @@
+set(lib_name ${PROJECT_NAME})
+########################################
+# source
+set(${lib_name}_libsrcs
+  auth.c
+  common.h
+  conn.c
+  crypto.c
+  ctx.c
+  event.c
+  handler.c
+  hash.c
+  hash.h
+  jid.c
+  md5.c
+  md5.h
+  ostypes.h
+  parser_expat.c
+  parser.h
+  #parser_libxml2.c # parser_expat instead
+  rand.c
+  rand.h
+  resolver.c
+  resolver.h
+  sasl.c
+  sasl.h
+  scram.c
+  scram.h
+  sha1.c
+  sha1.h
+  snprintf.c
+  snprintf.h
+  sock.c
+  sock.h
+  stanza.c
+  #tls_dummy.c # tls_openssl instead
+  #tls_gnutls.c # tls_openssl instead
+  tls.h
+  tls_openssl.c
+  #tls_schannel.c # tls_openssl instead
+  util.c
+  util.h
+  uuid.c
+  )
+source_group("" FILES ${${lib_name}_libsrcs})
+########################################
+# library
+add_library(${lib_name} STATIC ${${lib_name}_libsrcs})
+target_link_libraries(${lib_name} ${EXPAT_LIBRARIES} ${OPENSSL_LIBRARIES} ${SYS_LIBS})
+target_include_directories(${lib_name} PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
+  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+  PRIVATE
+  $<BUILD_INTERFACE:${EXPAT_INCLUDE_DIRS}>
+  $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>
+  )
+set_target_properties(${lib_name} PROPERTIES
+  OUTPUT_NAME ${lib_name}${ver}
+  PREFIX "" # strip off the "lib" prefix, since it's already libstrophe
+  )
+########################################
+# install
+set(targetsFile ${PROJECT_NAME}${ver}-targets)
+install(TARGETS ${lib_name} EXPORT ${targetsFile}
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  ARCHIVE DESTINATION lib
+  )
+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
+  res_query_dump
+  test_base64
+  test_ctx
+  test_hash
+  test_jid
+  test_md5
+  test_rand
+  test_resolver
+  test_sasl
+  test_scram
+  test_sha1
+  test_snprintf
+  test_sock
+  test_string
+  )
+foreach(exe ${tests})
+  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${exe}.c) # there are some tests only in repo, not in download
+    add_executable(${exe} ${exe}.c)
+    target_link_libraries(${exe} testlib)
+    add_test(NAME ${exe} COMMAND ${exe})
+    set_property(TARGET ${exe} PROPERTY FOLDER tests)
+  endif()
+endforeach()
{'fraction_non_alphanumeric': 0.19938962360122076, 'fraction_numerical': 0.018681217053546657, 'mean_word_length': 5.8443037974683545, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 8, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1530868', 'n_tokens_mistral': 4545, 'n_tokens_neox': 4212, 'n_words': 757}