#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
# targets.cmake.ezt -- template for targets.cmake file
# targets.cmake -- list of CMake targets
#

# AFL fuzzer for svndiff to txdelta parser
if (SVN_ENABLE_TESTS)
  add_executable(afl-svndiff
    subversion/tests/afl/afl-svndiff.c
  )
  if (WIN32)
    target_sources(afl-svndiff PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(afl-svndiff PRIVATE
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(afl-svndiff PRIVATE
    "SVN_FILE_DESCRIPTION=AFL fuzzer for svndiff to txdelta parser"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:afl-svndiff>"
  )
  if (WIN32)
    target_sources(afl-svndiff PRIVATE build/win32/svn.rc)
  endif()
endif()

# AFL fuzzer for x509 parser
if (SVN_ENABLE_TESTS)
  add_executable(afl-x509
    subversion/tests/afl/afl-x509.c
  )
  if (WIN32)
    target_sources(afl-x509 PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(afl-x509 PRIVATE
    libsvn_subr
    external-apr
  )
  target_compile_definitions(afl-x509 PRIVATE
    "SVN_FILE_DESCRIPTION=AFL fuzzer for x509 parser"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:afl-x509>"
  )
  if (WIN32)
    target_sources(afl-x509 PRIVATE build/win32/svn.rc)
  endif()
endif()

# atomic-ra-revprop-change
if (SVN_ENABLE_TESTS)
  add_executable(atomic-ra-revprop-change
    subversion/tests/cmdline/atomic-ra-revprop-change.c
  )
  if (WIN32)
    target_sources(atomic-ra-revprop-change PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(atomic-ra-revprop-change PRIVATE
    libsvn_ra
    libsvn_subr
    external-apr
  )
  target_compile_definitions(atomic-ra-revprop-change PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:atomic-ra-revprop-change>"
  )
  if (WIN32)
    target_sources(atomic-ra-revprop-change PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test platform-specific auth provider access
if (SVN_ENABLE_TESTS)
  add_executable(auth-test
    subversion/tests/libsvn_subr/auth-test.c
  )
  add_test(
    NAME libsvn_subr.auth-test
    COMMAND auth-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:auth-test>
  )
  set_tests_properties(libsvn_subr.auth-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:auth-test>)
  target_link_libraries(auth-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(auth-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test platform-specific auth provider access"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:auth-test>"
  )
  if (WIN32)
    target_sources(auth-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test authz parsing in libsvn_repos
if (SVN_ENABLE_TESTS)
  add_executable(authz-test
    subversion/tests/libsvn_repos/authz-test.c
  )
  add_test(
    NAME libsvn_repos.authz-test
    COMMAND authz-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_repos
    WORKING_DIRECTORY $<TARGET_FILE_DIR:authz-test>
  )
  set_tests_properties(libsvn_repos.authz-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:authz-test>)
  target_link_libraries(authz-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(authz-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test authz parsing in libsvn_repos"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:authz-test>"
  )
  if (WIN32)
    target_sources(authz-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test packed bit arrays
if (SVN_ENABLE_TESTS)
  add_executable(bit-array-test
    subversion/tests/libsvn_subr/bit-array-test.c
  )
  add_test(
    NAME libsvn_subr.bit-array-test
    COMMAND bit-array-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:bit-array-test>
  )
  set_tests_properties(libsvn_subr.bit-array-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:bit-array-test>)
  target_link_libraries(bit-array-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(bit-array-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test packed bit arrays"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:bit-array-test>"
  )
  if (WIN32)
    target_sources(bit-array-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test in-memory cache
if (SVN_ENABLE_TESTS)
  add_executable(cache-test
    subversion/tests/libsvn_subr/cache-test.c
  )
  add_test(
    NAME libsvn_subr.cache-test
    COMMAND cache-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:cache-test>
  )
  set_tests_properties(libsvn_subr.cache-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:cache-test>)
  target_link_libraries(cache-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(cache-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test in-memory cache"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:cache-test>"
  )
  if (WIN32)
    target_sources(cache-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test changes in libsvn_fs_base
if (SVN_ENABLE_FS_BASE AND SVN_ENABLE_PROGRAMS)
  add_executable(changes-test
    subversion/tests/libsvn_fs_base/changes-test.c
  )
  if (WIN32)
    target_sources(changes-test PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(changes-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_fs_base
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(changes-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test changes in libsvn_fs_base"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:changes-test>"
  )
  if (WIN32)
    target_sources(changes-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test checksum functions
if (SVN_ENABLE_TESTS)
  add_executable(checksum-test
    subversion/tests/libsvn_subr/checksum-test.c
  )
  add_test(
    NAME libsvn_subr.checksum-test
    COMMAND checksum-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:checksum-test>
  )
  set_tests_properties(libsvn_subr.checksum-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:checksum-test>)
  target_link_libraries(checksum-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
    external-zlib
  )
  target_compile_definitions(checksum-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test checksum functions"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:checksum-test>"
  )
  if (WIN32)
    target_sources(checksum-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test low-level functionality in libsvn_client
if (SVN_ENABLE_TESTS)
  add_executable(client-test
    subversion/tests/libsvn_client/client-test.c
  )
  add_test(
    NAME libsvn_client.client-test
    COMMAND client-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_client
    WORKING_DIRECTORY $<TARGET_FILE_DIR:client-test>
  )
  set_tests_properties(libsvn_client.client-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:client-test>)
  target_link_libraries(client-test PRIVATE
    libsvn_test
    libsvn_client
    libsvn_wc
    libsvn_repos
    libsvn_ra
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(client-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test low-level functionality in libsvn_client"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:client-test>"
  )
  if (WIN32)
    target_sources(client-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test compatibility functions
if (SVN_ENABLE_TESTS)
  add_executable(compat-test
    subversion/tests/libsvn_subr/compat-test.c
  )
  add_test(
    NAME libsvn_subr.compat-test
    COMMAND compat-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:compat-test>
  )
  set_tests_properties(libsvn_subr.compat-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:compat-test>)
  target_link_libraries(compat-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(compat-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test compatibility functions"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:compat-test>"
  )
  if (WIN32)
    target_sources(compat-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test compression functions
if (SVN_ENABLE_TESTS)
  add_executable(compress-test
    subversion/tests/libsvn_subr/compress-test.c
  )
  add_test(
    NAME libsvn_subr.compress-test
    COMMAND compress-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:compress-test>
  )
  set_tests_properties(libsvn_subr.compress-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:compress-test>)
  target_link_libraries(compress-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(compress-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test compression functions"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:compress-test>"
  )
  if (WIN32)
    target_sources(compress-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test svn_config utilities
if (SVN_ENABLE_TESTS)
  add_executable(config-test
    subversion/tests/libsvn_subr/config-test.c
  )
  add_test(
    NAME libsvn_subr.config-test
    COMMAND config-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:config-test>
  )
  set_tests_properties(libsvn_subr.config-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:config-test>)
  target_link_libraries(config-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(config-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test svn_config utilities"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:config-test>"
  )
  if (WIN32)
    target_sources(config-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test the storage of tree conflict data
if (SVN_ENABLE_TESTS)
  add_executable(conflict-data-test
    subversion/tests/libsvn_wc/conflict-data-test.c
    subversion/tests/libsvn_wc/utils.c
  )
  add_test(
    NAME libsvn_wc.conflict-data-test
    COMMAND conflict-data-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_wc
    WORKING_DIRECTORY $<TARGET_FILE_DIR:conflict-data-test>
  )
  set_tests_properties(libsvn_wc.conflict-data-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:conflict-data-test>)
  target_link_libraries(conflict-data-test PRIVATE
    libsvn_client
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(conflict-data-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test the storage of tree conflict data"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:conflict-data-test>"
  )
  if (WIN32)
    target_sources(conflict-data-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test libsvn_client conflict resolver
if (SVN_ENABLE_TESTS)
  add_executable(conflicts-test
    subversion/tests/libsvn_client/../libsvn_wc/utils.c
    subversion/tests/libsvn_client/conflicts-test.c
  )
  add_test(
    NAME libsvn_client.conflicts-test
    COMMAND conflicts-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_client
    WORKING_DIRECTORY $<TARGET_FILE_DIR:conflicts-test>
  )
  set_tests_properties(libsvn_client.conflicts-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:conflicts-test>)
  target_link_libraries(conflicts-test PRIVATE
    libsvn_test
    libsvn_client
    libsvn_wc
    libsvn_repos
    libsvn_ra
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(conflicts-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test libsvn_client conflict resolver"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:conflicts-test>"
  )
  if (WIN32)
    target_sources(conflicts-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test svn_crypto utilities
if (SVN_ENABLE_TESTS)
  add_executable(crypto-test
    subversion/tests/libsvn_subr/crypto-test.c
  )
  add_test(
    NAME libsvn_subr.crypto-test
    COMMAND crypto-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:crypto-test>
  )
  set_tests_properties(libsvn_subr.crypto-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:crypto-test>)
  target_link_libraries(crypto-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-aprutil
    external-apr
  )
  target_compile_definitions(crypto-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test svn_crypto utilities"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:crypto-test>"
  )
  if (WIN32)
    target_sources(crypto-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test the wc-ng database subsystem
if (SVN_ENABLE_TESTS)
  add_executable(db-test
    subversion/tests/libsvn_wc/db-test.c
    subversion/tests/libsvn_wc/utils.c
  )
  add_test(
    NAME libsvn_wc.db-test
    COMMAND db-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_wc
    WORKING_DIRECTORY $<TARGET_FILE_DIR:db-test>
  )
  set_tests_properties(libsvn_wc.db-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:db-test>)
  target_link_libraries(db-test PRIVATE
    libsvn_client
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(db-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test the wc-ng database subsystem"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:db-test>"
  )
  if (WIN32)
    target_sources(db-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# diff
if (SVN_ENABLE_TOOLS)
  add_executable(diff
    tools/diff/diff.c
  )
  if (WIN32)
    target_sources(diff PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(diff PRIVATE
    libsvn_diff
    libsvn_subr
    external-apr
  )
  target_compile_definitions(diff PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:diff>"
  )
  if (WIN32)
    target_sources(diff PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test the diff/diff3 library
if (SVN_ENABLE_TESTS)
  add_executable(diff-diff3-test
    subversion/tests/libsvn_diff/diff-diff3-test.c
  )
  add_test(
    NAME libsvn_diff.diff-diff3-test
    COMMAND diff-diff3-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_diff
    WORKING_DIRECTORY $<TARGET_FILE_DIR:diff-diff3-test>
  )
  set_tests_properties(libsvn_diff.diff-diff3-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:diff-diff3-test>)
  target_link_libraries(diff-diff3-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_diff
    libsvn_subr
    external-apr
  )
  target_compile_definitions(diff-diff3-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test the diff/diff3 library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:diff-diff3-test>"
  )
  if (WIN32)
    target_sources(diff-diff3-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# diff3
if (SVN_ENABLE_TOOLS)
  add_executable(diff3
    tools/diff/diff3.c
  )
  if (WIN32)
    target_sources(diff3 PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(diff3 PRIVATE
    libsvn_diff
    libsvn_subr
    external-apr
  )
  target_compile_definitions(diff3 PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:diff3>"
  )
  if (WIN32)
    target_sources(diff3 PRIVATE build/win32/svn.rc)
  endif()
endif()

# diff4
if (SVN_ENABLE_TOOLS)
  add_executable(diff4
    tools/diff/diff4.c
  )
  if (WIN32)
    target_sources(diff4 PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(diff4 PRIVATE
    libsvn_diff
    libsvn_subr
    external-apr
  )
  target_compile_definitions(diff4 PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:diff4>"
  )
  if (WIN32)
    target_sources(diff4 PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test dirent_uri library
if (SVN_ENABLE_TESTS)
  add_executable(dirent_uri-test
    subversion/tests/libsvn_subr/dirent_uri-test.c
  )
  add_test(
    NAME libsvn_subr.dirent_uri-test
    COMMAND dirent_uri-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:dirent_uri-test>
  )
  set_tests_properties(libsvn_subr.dirent_uri-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:dirent_uri-test>)
  target_link_libraries(dirent_uri-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(dirent_uri-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test dirent_uri library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:dirent_uri-test>"
  )
  if (WIN32)
    target_sources(dirent_uri-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test dumping/loading repositories in libsvn_repos
if (SVN_ENABLE_TESTS)
  add_executable(dump-load-test
    subversion/tests/libsvn_repos/dump-load-test.c
  )
  add_test(
    NAME libsvn_repos.dump-load-test
    COMMAND dump-load-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_repos
    WORKING_DIRECTORY $<TARGET_FILE_DIR:dump-load-test>
  )
  set_tests_properties(libsvn_repos.dump-load-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:dump-load-test>)
  target_link_libraries(dump-load-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(dump-load-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test dumping/loading repositories in libsvn_repos"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:dump-load-test>"
  )
  if (WIN32)
    target_sources(dump-load-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test backwards compat for the entry interface
if (SVN_ENABLE_TESTS)
  add_executable(entries-compat-test
    subversion/tests/libsvn_wc/entries-compat.c
    subversion/tests/libsvn_wc/utils.c
  )
  add_test(
    NAME libsvn_wc.entries-compat-test
    COMMAND entries-compat-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_wc
    WORKING_DIRECTORY $<TARGET_FILE_DIR:entries-compat-test>
  )
  set_tests_properties(libsvn_wc.entries-compat-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:entries-compat-test>)
  target_link_libraries(entries-compat-test PRIVATE
    libsvn_client
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(entries-compat-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test backwards compat for the entry interface"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:entries-compat-test>"
  )
  if (WIN32)
    target_sources(entries-compat-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# entries-dump
if (SVN_ENABLE_TESTS)
  add_executable(entries-dump
    subversion/tests/cmdline/entries-dump.c
  )
  if (WIN32)
    target_sources(entries-dump PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(entries-dump PRIVATE
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(entries-dump PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:entries-dump>"
  )
  if (WIN32)
    target_sources(entries-dump PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test error library
if (SVN_ENABLE_TESTS)
  add_executable(error-code-test
    subversion/tests/libsvn_subr/error-code-test.c
  )
  add_test(
    NAME libsvn_subr.error-code-test
    COMMAND error-code-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:error-code-test>
  )
  set_tests_properties(libsvn_subr.error-code-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:error-code-test>)
  target_link_libraries(error-code-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(error-code-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test error library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:error-code-test>"
  )
  if (WIN32)
    target_sources(error-code-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test error library
if (SVN_ENABLE_TESTS)
  add_executable(error-test
    subversion/tests/libsvn_subr/error-test.c
  )
  add_test(
    NAME libsvn_subr.error-test
    COMMAND error-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:error-test>
  )
  set_tests_properties(libsvn_subr.error-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:error-test>)
  target_link_libraries(error-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(error-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test error library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:error-test>"
  )
  if (WIN32)
    target_sources(error-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test conversion of file sizes to human-readable form
if (SVN_ENABLE_TESTS)
  add_executable(filesize-test
    subversion/tests/client/filesize-test.c
  )
  add_test(
    NAME client.filesize-test
    COMMAND filesize-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/client
    WORKING_DIRECTORY $<TARGET_FILE_DIR:filesize-test>
  )
  set_tests_properties(client.filesize-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:filesize-test>)
  target_link_libraries(filesize-test PRIVATE
    libsvn_client
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(filesize-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test conversion of file sizes to human-readable form"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:filesize-test>"
  )
  if (WIN32)
    target_sources(filesize-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Tests for *public* fs API (svn_fs.h)
if (SVN_ENABLE_FS_BASE AND SVN_ENABLE_PROGRAMS)
  add_executable(fs-base-test
    subversion/tests/libsvn_fs_base/fs-base-test.c
  )
  if (WIN32)
    target_sources(fs-base-test PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(fs-base-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_fs_base
    libsvn_delta
    libsvn_fs_util
    libsvn_subr
    external-apr
  )
  target_compile_definitions(fs-base-test PRIVATE
    "SVN_FILE_DESCRIPTION=Tests for *public* fs API (svn_fs.h)"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:fs-base-test>"
  )
  if (WIN32)
    target_sources(fs-base-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Use fuzzying to test FSFS corruption resilience
if (SVN_ENABLE_TESTS AND SVN_ENABLE_FS_FS)
  add_executable(fs-fs-fuzzy-test
    subversion/tests/libsvn_fs_fs/fs-fs-fuzzy-test.c
  )
  if (WIN32)
    target_sources(fs-fs-fuzzy-test PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(fs-fs-fuzzy-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_fs_fs
    libsvn_delta
    libsvn_repos
    libsvn_subr
    external-apr
  )
  target_compile_definitions(fs-fs-fuzzy-test PRIVATE
    "SVN_FILE_DESCRIPTION=Use fuzzying to test FSFS corruption resilience"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:fs-fs-fuzzy-test>"
  )
  if (WIN32)
    target_sources(fs-fs-fuzzy-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test fsfs packing in libsvn_fs_fs
if (SVN_ENABLE_TESTS AND SVN_ENABLE_FS_FS)
  add_executable(fs-fs-pack-test
    subversion/tests/libsvn_fs_fs/fs-fs-pack-test.c
  )
  add_test(
    NAME libsvn_fs_fs.fs-fs-pack-test
    COMMAND fs-fs-pack-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_fs_fs
    WORKING_DIRECTORY $<TARGET_FILE_DIR:fs-fs-pack-test>
  )
  set_tests_properties(libsvn_fs_fs.fs-fs-pack-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:fs-fs-pack-test>)
  target_link_libraries(fs-fs-pack-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_fs_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(fs-fs-pack-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test fsfs packing in libsvn_fs_fs"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:fs-fs-pack-test>"
  )
  if (WIN32)
    target_sources(fs-fs-pack-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test FSFS private API
if (SVN_ENABLE_TESTS AND SVN_ENABLE_FS_FS)
  add_executable(fs-fs-private-test
    subversion/tests/libsvn_fs_fs/fs-fs-private-test.c
  )
  add_test(
    NAME libsvn_fs_fs.fs-fs-private-test
    COMMAND fs-fs-private-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_fs_fs
    WORKING_DIRECTORY $<TARGET_FILE_DIR:fs-fs-private-test>
  )
  set_tests_properties(libsvn_fs_fs.fs-fs-private-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:fs-fs-private-test>)
  target_link_libraries(fs-fs-private-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_fs_fs
    libsvn_delta
    libsvn_repos
    libsvn_subr
    external-apr
  )
  target_compile_definitions(fs-fs-private-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test FSFS private API"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:fs-fs-private-test>"
  )
  if (WIN32)
    target_sources(fs-fs-private-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Tests in libsvn_fs run sequentially
if (SVN_ENABLE_TESTS)
  add_executable(fs-sequential-test
    subversion/tests/libsvn_fs/fs-sequential-test.c
  )
  add_test(
    NAME libsvn_fs.fs-sequential-test
    COMMAND fs-sequential-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_fs
    WORKING_DIRECTORY $<TARGET_FILE_DIR:fs-sequential-test>
  )
  set_tests_properties(libsvn_fs.fs-sequential-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:fs-sequential-test>)
  target_link_libraries(fs-sequential-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_delta
    libsvn_fs_util
    libsvn_subr
    external-aprutil
    external-apr
  )
  target_compile_definitions(fs-sequential-test PRIVATE
    "SVN_FILE_DESCRIPTION=Tests in libsvn_fs run sequentially"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:fs-sequential-test>"
  )
  if (WIN32)
    target_sources(fs-sequential-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Tests in libsvn_fs
if (SVN_ENABLE_TESTS)
  add_executable(fs-test
    subversion/tests/libsvn_fs/fs-test.c
  )
  add_test(
    NAME libsvn_fs.fs-test
    COMMAND fs-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_fs
    WORKING_DIRECTORY $<TARGET_FILE_DIR:fs-test>
  )
  set_tests_properties(libsvn_fs.fs-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:fs-test>)
  target_link_libraries(fs-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_delta
    libsvn_fs_util
    libsvn_subr
    external-aprutil
    external-apr
  )
  target_compile_definitions(fs-test PRIVATE
    "SVN_FILE_DESCRIPTION=Tests in libsvn_fs"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:fs-test>"
  )
  if (WIN32)
    target_sources(fs-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test fsx packing in libsvn_fs_x
if (SVN_ENABLE_TESTS AND SVN_ENABLE_FS_X)
  add_executable(fs-x-pack-test
    subversion/tests/libsvn_fs_x/fs-x-pack-test.c
  )
  add_test(
    NAME libsvn_fs_x.fs-x-pack-test
    COMMAND fs-x-pack-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_fs_x
    WORKING_DIRECTORY $<TARGET_FILE_DIR:fs-x-pack-test>
  )
  set_tests_properties(libsvn_fs_x.fs-x-pack-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:fs-x-pack-test>)
  target_link_libraries(fs-x-pack-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_fs_x
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(fs-x-pack-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test fsx packing in libsvn_fs_x"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:fs-x-pack-test>"
  )
  if (WIN32)
    target_sources(fs-x-pack-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# fsfs-access-map
if (SVN_ENABLE_TOOLS)
  add_executable(fsfs-access-map
    tools/dev/fsfs-access-map.c
  )
  if (WIN32)
    target_sources(fsfs-access-map PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(fsfs-access-map PRIVATE
    libsvn_subr
    external-apr
  )
  target_compile_definitions(fsfs-access-map PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:fsfs-access-map>"
  )
  if (WIN32)
    target_sources(fsfs-access-map PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test hashfile format for props
if (SVN_ENABLE_TESTS)
  add_executable(hashdump-test
    subversion/tests/libsvn_subr/hashdump-test.c
  )
  add_test(
    NAME libsvn_subr.hashdump-test
    COMMAND hashdump-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:hashdump-test>
  )
  set_tests_properties(libsvn_subr.hashdump-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:hashdump-test>)
  target_link_libraries(hashdump-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(hashdump-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test hashfile format for props"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:hashdump-test>"
  )
  if (WIN32)
    target_sources(hashdump-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test I/O Operations
if (SVN_ENABLE_TESTS)
  add_executable(io-test
    subversion/tests/libsvn_subr/io-test.c
  )
  add_test(
    NAME libsvn_subr.io-test
    COMMAND io-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:io-test>
  )
  set_tests_properties(libsvn_subr.io-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:io-test>)
  target_link_libraries(io-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(io-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test I/O Operations"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:io-test>"
  )
  if (WIN32)
    target_sources(io-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Subversion GNOME Keyring Library
if (SVN_ENABLE_AUTH_GNOME_KEYRING)
  add_library(libsvn_auth_gnome_keyring
    subversion/libsvn_auth_gnome_keyring/gnome_keyring.c
    subversion/libsvn_auth_gnome_keyring/version.c
  )
  set_target_properties(libsvn_auth_gnome_keyring PROPERTIES OUTPUT_NAME "svn_auth_gnome_keyring-1")
  set_target_properties(libsvn_auth_gnome_keyring PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_auth_gnome_keyring PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_auth_gnome_keyring PUBLIC
    external-apr
  )
  target_link_libraries(libsvn_auth_gnome_keyring PRIVATE
    libsvn_subr
    external-gnome-keyring
  )
  target_compile_definitions(libsvn_auth_gnome_keyring PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion GNOME Keyring Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_auth_gnome_keyring>"
  )
  if (WIN32)
    target_sources(libsvn_auth_gnome_keyring PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_auth_gnome_keyring)
endif()

# Subversion KWallet Library
if (SVN_ENABLE_AUTH_KWALLET)
  add_library(libsvn_auth_kwallet
    subversion/libsvn_auth_kwallet/kwallet.cpp
    subversion/libsvn_auth_kwallet/version.c
  )
  set_target_properties(libsvn_auth_kwallet PROPERTIES OUTPUT_NAME "svn_auth_kwallet-1")
  set_target_properties(libsvn_auth_kwallet PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_auth_kwallet PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_auth_kwallet PUBLIC
    external-apr
  )
  target_link_libraries(libsvn_auth_kwallet PRIVATE
    libsvn_subr
    external-kwallet
  )
  target_compile_definitions(libsvn_auth_kwallet PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion KWallet Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_auth_kwallet>"
  )
  if (WIN32)
    target_sources(libsvn_auth_kwallet PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_auth_kwallet)
endif()

# Subversion Client Library
if (TRUE)
  add_library(libsvn_client
    subversion/libsvn_client/add.c
    subversion/libsvn_client/blame.c
    subversion/libsvn_client/cat.c
    subversion/libsvn_client/changelist.c
    subversion/libsvn_client/checkout.c
    subversion/libsvn_client/cleanup.c
    subversion/libsvn_client/cmdline.c
    subversion/libsvn_client/commit.c
    subversion/libsvn_client/commit_util.c
    subversion/libsvn_client/compat_providers.c
    subversion/libsvn_client/conflicts.c
    subversion/libsvn_client/copy.c
    subversion/libsvn_client/ctx.c
    subversion/libsvn_client/delete.c
    subversion/libsvn_client/deprecated.c
    subversion/libsvn_client/diff.c
    subversion/libsvn_client/diff_local.c
    subversion/libsvn_client/diff_patch.c
    subversion/libsvn_client/diff_summarize.c
    subversion/libsvn_client/export.c
    subversion/libsvn_client/externals.c
    subversion/libsvn_client/import.c
    subversion/libsvn_client/info.c
    subversion/libsvn_client/iprops.c
    subversion/libsvn_client/layout.c
    subversion/libsvn_client/list.c
    subversion/libsvn_client/locking_commands.c
    subversion/libsvn_client/log.c
    subversion/libsvn_client/merge.c
    subversion/libsvn_client/mergeinfo.c
    subversion/libsvn_client/mtcc.c
    subversion/libsvn_client/patch.c
    subversion/libsvn_client/prop_commands.c
    subversion/libsvn_client/ra.c
    subversion/libsvn_client/relocate.c
    subversion/libsvn_client/repos_diff.c
    subversion/libsvn_client/resolved.c
    subversion/libsvn_client/revert.c
    subversion/libsvn_client/revisions.c
    subversion/libsvn_client/shelf.c
    subversion/libsvn_client/shelf2.c
    subversion/libsvn_client/status.c
    subversion/libsvn_client/switch.c
    subversion/libsvn_client/textbase.c
    subversion/libsvn_client/update.c
    subversion/libsvn_client/upgrade.c
    subversion/libsvn_client/url.c
    subversion/libsvn_client/util.c
    subversion/libsvn_client/version.c
    subversion/libsvn_client/wc_editor.c
  )
  target_exports(libsvn_client
    subversion/include/svn_client.h
    subversion/include/private/svn_client_mtcc.h
    subversion/include/private/svn_client_private.h
    subversion/include/private/svn_client_shelf.h
    subversion/include/private/svn_client_shelf2.h
    subversion/include/../libsvn_client/mergeinfo.h
    subversion/include/../libsvn_client/client.h
  )
  set_target_properties(libsvn_client PROPERTIES OUTPUT_NAME "svn_client-1")
  set_target_properties(libsvn_client PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_client PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_client PUBLIC
    external-apr
  )
  target_link_libraries(libsvn_client PRIVATE
    libsvn_wc
    libsvn_ra
    libsvn_delta
    libsvn_diff
    libsvn_subr
  )
  target_compile_definitions(libsvn_client PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Client Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_client>"
  )
  if (WIN32)
    target_sources(libsvn_client PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_client)
endif()

# Subversion Delta Library
if (TRUE)
  add_library(libsvn_delta
    subversion/libsvn_delta/cancel.c
    subversion/libsvn_delta/compat.c
    subversion/libsvn_delta/compose_delta.c
    subversion/libsvn_delta/debug_editor.c
    subversion/libsvn_delta/default_editor.c
    subversion/libsvn_delta/deprecated.c
    subversion/libsvn_delta/depth_filter_editor.c
    subversion/libsvn_delta/editor.c
    subversion/libsvn_delta/path_driver.c
    subversion/libsvn_delta/svndiff.c
    subversion/libsvn_delta/text_delta.c
    subversion/libsvn_delta/version.c
    subversion/libsvn_delta/xdelta.c
  )
  target_exports(libsvn_delta
    subversion/include/svn_delta.h
    subversion/include/private/svn_editor.h
    subversion/include/private/svn_delta_private.h
  )
  set_target_properties(libsvn_delta PROPERTIES OUTPUT_NAME "svn_delta-1")
  set_target_properties(libsvn_delta PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_delta PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_delta PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_delta PRIVATE
    libsvn_subr
    external-zlib
  )
  target_compile_definitions(libsvn_delta PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Delta Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_delta>"
  )
  if (WIN32)
    target_sources(libsvn_delta PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_delta)
endif()

# Subversion Diff Library
if (TRUE)
  add_library(libsvn_diff
    subversion/libsvn_diff/binary_diff.c
    subversion/libsvn_diff/deprecated.c
    subversion/libsvn_diff/diff.c
    subversion/libsvn_diff/diff3.c
    subversion/libsvn_diff/diff4.c
    subversion/libsvn_diff/diff_file.c
    subversion/libsvn_diff/diff_memory.c
    subversion/libsvn_diff/diff_tree.c
    subversion/libsvn_diff/diff_tree_copy_as_changed.c
    subversion/libsvn_diff/diff_tree_debug.c
    subversion/libsvn_diff/diff_tree_filter.c
    subversion/libsvn_diff/diff_tree_reverse.c
    subversion/libsvn_diff/diff_tree_tee.c
    subversion/libsvn_diff/lcs.c
    subversion/libsvn_diff/parse-diff.c
    subversion/libsvn_diff/token.c
    subversion/libsvn_diff/util.c
  )
  target_exports(libsvn_diff
    subversion/include/svn_diff.h
    subversion/include/private/svn_diff_private.h
    subversion/include/private/svn_diff_tree.h
  )
  set_target_properties(libsvn_diff PROPERTIES OUTPUT_NAME "svn_diff-1")
  set_target_properties(libsvn_diff PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_diff PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_diff PUBLIC
    external-apr
  )
  target_link_libraries(libsvn_diff PRIVATE
    libsvn_subr
    external-zlib
  )
  target_compile_definitions(libsvn_diff PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Diff Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_diff>"
  )
  if (WIN32)
    target_sources(libsvn_diff PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_diff)
endif()

# Subversion Repository Filesystem Library
if (TRUE)
  add_library(libsvn_fs
    subversion/libsvn_fs/access.c
    subversion/libsvn_fs/deprecated.c
    subversion/libsvn_fs/editor.c
    subversion/libsvn_fs/fs-loader.c
  )
  target_exports(libsvn_fs
    subversion/include/svn_fs.h
    subversion/include/private/svn_fs_private.h
  )
  set_target_properties(libsvn_fs PROPERTIES OUTPUT_NAME "svn_fs-1")
  set_target_properties(libsvn_fs PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_fs PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_fs PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_fs PRIVATE
    libsvn_fs_util
    libsvn_delta
    libsvn_subr
    fs-libs
  )
  target_compile_definitions(libsvn_fs PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Repository Filesystem Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_fs>"
  )
  if (WIN32)
    target_sources(libsvn_fs PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_fs)
endif()

# Subversion Filesystem Base Library
if (SVN_ENABLE_FS_BASE)
  add_library(libsvn_fs_base ${SVN_FS_BUILD_TYPE}
    subversion/libsvn_fs_base/bdb/bdb-err.c
    subversion/libsvn_fs_base/bdb/bdb_compat.c
    subversion/libsvn_fs_base/bdb/changes-table.c
    subversion/libsvn_fs_base/bdb/checksum-reps-table.c
    subversion/libsvn_fs_base/bdb/copies-table.c
    subversion/libsvn_fs_base/bdb/dbt.c
    subversion/libsvn_fs_base/bdb/env.c
    subversion/libsvn_fs_base/bdb/lock-tokens-table.c
    subversion/libsvn_fs_base/bdb/locks-table.c
    subversion/libsvn_fs_base/bdb/miscellaneous-table.c
    subversion/libsvn_fs_base/bdb/node-origins-table.c
    subversion/libsvn_fs_base/bdb/nodes-table.c
    subversion/libsvn_fs_base/bdb/reps-table.c
    subversion/libsvn_fs_base/bdb/rev-table.c
    subversion/libsvn_fs_base/bdb/strings-table.c
    subversion/libsvn_fs_base/bdb/txn-table.c
    subversion/libsvn_fs_base/bdb/uuids-table.c
    subversion/libsvn_fs_base/dag.c
    subversion/libsvn_fs_base/err.c
    subversion/libsvn_fs_base/fs.c
    subversion/libsvn_fs_base/id.c
    subversion/libsvn_fs_base/key-gen.c
    subversion/libsvn_fs_base/lock.c
    subversion/libsvn_fs_base/node-rev.c
    subversion/libsvn_fs_base/reps-strings.c
    subversion/libsvn_fs_base/revs-txns.c
    subversion/libsvn_fs_base/trail.c
    subversion/libsvn_fs_base/tree.c
    subversion/libsvn_fs_base/util/fs_skels.c
    subversion/libsvn_fs_base/uuid.c
  )
  target_exports(libsvn_fs_base
    subversion/include/../libsvn_fs_base/fs_init.h
    subversion/include/../libsvn_fs_base/fs.h
    subversion/include/../libsvn_fs_base/id.h
    subversion/include/../libsvn_fs_base/key-gen.h
    subversion/include/../libsvn_fs_base/lock.h
    subversion/include/../libsvn_fs_base/trail.h
    subversion/include/../libsvn_fs_base/util/fs_skels.h
    subversion/include/../libsvn_fs_base/bdb/changes-table.h
    subversion/include/../libsvn_fs_base/bdb/txn-table.h
    subversion/include/../libsvn_fs_base/bdb/nodes-table.h
    subversion/include/../libsvn_fs_base/bdb/strings-table.h
    subversion/include/../libsvn_fs_base/bdb/reps-table.h
  )
  set_target_properties(libsvn_fs_base PROPERTIES OUTPUT_NAME "svn_fs_base-1")
  set_target_properties(libsvn_fs_base PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_fs_base PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(fs-libs INTERFACE libsvn_fs_base)
  target_link_libraries(libsvn_fs_base PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_fs_base PRIVATE
    libsvn_delta
    libsvn_subr
    external-bdb
    libsvn_fs_util
  )
  target_compile_definitions(libsvn_fs_base PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Filesystem Base Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_fs_base>"
  )
  if (WIN32)
    target_sources(libsvn_fs_base PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_fs_base)
endif()

# Subversion FSFS Repository Filesystem Library
if (SVN_ENABLE_FS_FS)
  add_library(libsvn_fs_fs ${SVN_FS_BUILD_TYPE}
    subversion/libsvn_fs_fs/cached_data.c
    subversion/libsvn_fs_fs/caching.c
    subversion/libsvn_fs_fs/dag.c
    subversion/libsvn_fs_fs/dump-index.c
    subversion/libsvn_fs_fs/fs.c
    subversion/libsvn_fs_fs/fs_fs.c
    subversion/libsvn_fs_fs/hotcopy.c
    subversion/libsvn_fs_fs/id.c
    subversion/libsvn_fs_fs/index.c
    subversion/libsvn_fs_fs/load-index.c
    subversion/libsvn_fs_fs/lock.c
    subversion/libsvn_fs_fs/low_level.c
    subversion/libsvn_fs_fs/pack.c
    subversion/libsvn_fs_fs/recovery.c
    subversion/libsvn_fs_fs/rep-cache.c
    subversion/libsvn_fs_fs/rev_file.c
    subversion/libsvn_fs_fs/revprops.c
    subversion/libsvn_fs_fs/stats.c
    subversion/libsvn_fs_fs/temp_serializer.c
    subversion/libsvn_fs_fs/transaction.c
    subversion/libsvn_fs_fs/tree.c
    subversion/libsvn_fs_fs/util.c
    subversion/libsvn_fs_fs/verify.c
  )
  target_exports(libsvn_fs_fs
    subversion/include/private/svn_fs_fs_private.h
    subversion/include/../libsvn_fs_fs/fs_init.h
    subversion/include/../libsvn_fs_fs/fs_fs.h
    subversion/include/../libsvn_fs_fs/fs.h
    subversion/include/../libsvn_fs_fs/id.h
    subversion/include/../libsvn_fs_fs/index.h
    subversion/include/../libsvn_fs_fs/low_level.h
    subversion/include/../libsvn_fs_fs/pack.h
    subversion/include/../libsvn_fs_fs/rep-cache.h
    subversion/include/../libsvn_fs_fs/rev_file.h
    subversion/include/../libsvn_fs_fs/util.h
  )
  set_target_properties(libsvn_fs_fs PROPERTIES OUTPUT_NAME "svn_fs_fs-1")
  set_target_properties(libsvn_fs_fs PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_fs_fs PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(fs-libs INTERFACE libsvn_fs_fs)
  target_link_libraries(libsvn_fs_fs PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_fs_fs PRIVATE
    libsvn_delta
    libsvn_subr
    libsvn_fs_util
  )
  if (WIN32)
    target_link_libraries(libsvn_fs_fs PRIVATE ws2_32.lib)
  endif()
  target_compile_definitions(libsvn_fs_fs PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion FSFS Repository Filesystem Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_fs_fs>"
  )
  if (WIN32)
    target_sources(libsvn_fs_fs PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_fs_fs)
endif()

# Subversion Filesystem Utility Library
if (TRUE)
  add_library(libsvn_fs_util
    subversion/libsvn_fs_util/fs-util.c
  )
  target_exports(libsvn_fs_util
    subversion/include/private/svn_fs_util.h
  )
  set_target_properties(libsvn_fs_util PROPERTIES OUTPUT_NAME "svn_fs_util-1")
  set_target_properties(libsvn_fs_util PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_fs_util PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_fs_util PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_fs_util PRIVATE
    libsvn_subr
  )
  if (WIN32)
    target_link_libraries(libsvn_fs_util PRIVATE advapi32.lib shfolder.lib)
  endif()
  target_compile_definitions(libsvn_fs_util PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Filesystem Utility Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_fs_util>"
  )
  if (WIN32)
    target_sources(libsvn_fs_util PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_fs_util)
endif()

# Subversion FSX Repository Filesystem Library
if (SVN_ENABLE_FS_X)
  add_library(libsvn_fs_x ${SVN_FS_BUILD_TYPE}
    subversion/libsvn_fs_x/batch_fsync.c
    subversion/libsvn_fs_x/cached_data.c
    subversion/libsvn_fs_x/caching.c
    subversion/libsvn_fs_x/changes.c
    subversion/libsvn_fs_x/dag.c
    subversion/libsvn_fs_x/dag_cache.c
    subversion/libsvn_fs_x/fs.c
    subversion/libsvn_fs_x/fs_id.c
    subversion/libsvn_fs_x/fs_x.c
    subversion/libsvn_fs_x/hotcopy.c
    subversion/libsvn_fs_x/id.c
    subversion/libsvn_fs_x/index.c
    subversion/libsvn_fs_x/lock.c
    subversion/libsvn_fs_x/low_level.c
    subversion/libsvn_fs_x/noderevs.c
    subversion/libsvn_fs_x/pack.c
    subversion/libsvn_fs_x/recovery.c
    subversion/libsvn_fs_x/rep-cache.c
    subversion/libsvn_fs_x/reps.c
    subversion/libsvn_fs_x/rev_file.c
    subversion/libsvn_fs_x/revprops.c
    subversion/libsvn_fs_x/string_table.c
    subversion/libsvn_fs_x/temp_serializer.c
    subversion/libsvn_fs_x/transaction.c
    subversion/libsvn_fs_x/tree.c
    subversion/libsvn_fs_x/util.c
    subversion/libsvn_fs_x/verify.c
  )
  target_exports(libsvn_fs_x
    subversion/include/../libsvn_fs_x/fs_init.h
    subversion/include/../libsvn_fs_x/batch_fsync.h
    subversion/include/../libsvn_fs_x/fs_init.h
    subversion/include/../libsvn_fs_x/fs_x.h
    subversion/include/../libsvn_fs_x/fs.h
    subversion/include/../libsvn_fs_x/hotcopy.h
    subversion/include/../libsvn_fs_x/reps.h
    subversion/include/../libsvn_fs_x/string_table.h
  )
  set_target_properties(libsvn_fs_x PROPERTIES OUTPUT_NAME "svn_fs_x-1")
  set_target_properties(libsvn_fs_x PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_fs_x PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(fs-libs INTERFACE libsvn_fs_x)
  target_link_libraries(libsvn_fs_x PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_fs_x PRIVATE
    libsvn_delta
    libsvn_subr
    libsvn_fs_util
  )
  if (WIN32)
    target_link_libraries(libsvn_fs_x PRIVATE ws2_32.lib)
  endif()
  target_compile_definitions(libsvn_fs_x PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion FSX Repository Filesystem Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_fs_x>"
  )
  if (WIN32)
    target_sources(libsvn_fs_x PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_fs_x)
endif()

# Subversion General Repository Access Library
if (TRUE)
  add_library(libsvn_ra
    subversion/libsvn_ra/compat.c
    subversion/libsvn_ra/debug_reporter.c
    subversion/libsvn_ra/deprecated.c
    subversion/libsvn_ra/editor.c
    subversion/libsvn_ra/ra_loader.c
    subversion/libsvn_ra/util.c
  )
  target_exports(libsvn_ra
    subversion/include/svn_ra.h
    subversion/include/private/svn_ra_private.h
  )
  set_target_properties(libsvn_ra PROPERTIES OUTPUT_NAME "svn_ra-1")
  set_target_properties(libsvn_ra PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_ra PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_ra PUBLIC
    external-apr
    external-aprutil
  )
  target_link_libraries(libsvn_ra PRIVATE
    libsvn_delta
    libsvn_subr
    ra-libs
  )
  target_compile_definitions(libsvn_ra PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion General Repository Access Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_ra>"
  )
  if (WIN32)
    target_sources(libsvn_ra PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_ra)
endif()

# Subversion Local Repository Access Library
if (SVN_ENABLE_RA_LOCAL)
  add_library(libsvn_ra_local ${SVN_RA_BUILD_TYPE}
    subversion/libsvn_ra_local/ra_plugin.c
    subversion/libsvn_ra_local/split_url.c
  )
  target_exports(libsvn_ra_local
    subversion/include/../libsvn_ra_local/ra_init.h
    subversion/include/../libsvn_ra_local/ra_local.h
  )
  set_target_properties(libsvn_ra_local PROPERTIES OUTPUT_NAME "svn_ra_local-1")
  set_target_properties(libsvn_ra_local PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_ra_local PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(ra-libs INTERFACE libsvn_ra_local)
  target_link_libraries(libsvn_ra_local PUBLIC
    external-apr
  )
  target_link_libraries(libsvn_ra_local PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_subr
  )
  target_compile_definitions(libsvn_ra_local PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Local Repository Access Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_ra_local>"
  )
  if (WIN32)
    target_sources(libsvn_ra_local PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_ra_local)
endif()

# Subversion HTTP/WebDAV Protocol Repository Access Library
if (SVN_ENABLE_RA_SERF)
  add_library(libsvn_ra_serf ${SVN_RA_BUILD_TYPE}
    subversion/libsvn_ra_serf/blame.c
    subversion/libsvn_ra_serf/blncache.c
    subversion/libsvn_ra_serf/commit.c
    subversion/libsvn_ra_serf/eagain_bucket.c
    subversion/libsvn_ra_serf/get_deleted_rev.c
    subversion/libsvn_ra_serf/get_file.c
    subversion/libsvn_ra_serf/get_lock.c
    subversion/libsvn_ra_serf/getdate.c
    subversion/libsvn_ra_serf/getlocations.c
    subversion/libsvn_ra_serf/getlocationsegments.c
    subversion/libsvn_ra_serf/getlocks.c
    subversion/libsvn_ra_serf/inherited_props.c
    subversion/libsvn_ra_serf/list.c
    subversion/libsvn_ra_serf/lock.c
    subversion/libsvn_ra_serf/log.c
    subversion/libsvn_ra_serf/merge.c
    subversion/libsvn_ra_serf/mergeinfo.c
    subversion/libsvn_ra_serf/multistatus.c
    subversion/libsvn_ra_serf/options.c
    subversion/libsvn_ra_serf/property.c
    subversion/libsvn_ra_serf/replay.c
    subversion/libsvn_ra_serf/request_body.c
    subversion/libsvn_ra_serf/sb_bucket.c
    subversion/libsvn_ra_serf/serf.c
    subversion/libsvn_ra_serf/stat.c
    subversion/libsvn_ra_serf/stream_bucket.c
    subversion/libsvn_ra_serf/update.c
    subversion/libsvn_ra_serf/util.c
    subversion/libsvn_ra_serf/util_error.c
    subversion/libsvn_ra_serf/xml.c
  )
  target_exports(libsvn_ra_serf
    subversion/include/../libsvn_ra_serf/ra_init.h
    subversion/include/../libsvn_ra_serf/ra_serf.h
  )
  set_target_properties(libsvn_ra_serf PROPERTIES OUTPUT_NAME "svn_ra_serf-1")
  set_target_properties(libsvn_ra_serf PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_ra_serf PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(ra-libs INTERFACE libsvn_ra_serf)
  target_link_libraries(libsvn_ra_serf PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_ra_serf PRIVATE
    libsvn_delta
    libsvn_subr
    external-serf
    external-zlib
  )
  target_compile_definitions(libsvn_ra_serf PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion HTTP/WebDAV Protocol Repository Access Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_ra_serf>"
  )
  if (WIN32)
    target_sources(libsvn_ra_serf PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_ra_serf)
endif()

# Subversion SVN Protocol Repository Access Library
if (SVN_ENABLE_RA_SVN)
  add_library(libsvn_ra_svn ${SVN_RA_BUILD_TYPE}
    subversion/libsvn_ra_svn/client.c
    subversion/libsvn_ra_svn/cram.c
    subversion/libsvn_ra_svn/cyrus_auth.c
    subversion/libsvn_ra_svn/deprecated.c
    subversion/libsvn_ra_svn/editorp.c
    subversion/libsvn_ra_svn/internal_auth.c
    subversion/libsvn_ra_svn/marshal.c
    subversion/libsvn_ra_svn/streams.c
    subversion/libsvn_ra_svn/version.c
    subversion/libsvn_ra_svn/wrapped_sasl.c
  )
  target_exports(libsvn_ra_svn
    subversion/include/../libsvn_ra_svn/ra_init.h
    subversion/include/svn_ra_svn.h
    subversion/include/private/svn_ra_svn_private.h
  )
  set_target_properties(libsvn_ra_svn PROPERTIES OUTPUT_NAME "svn_ra_svn-1")
  set_target_properties(libsvn_ra_svn PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_ra_svn PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(ra-libs INTERFACE libsvn_ra_svn)
  target_link_libraries(libsvn_ra_svn PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_ra_svn PRIVATE
    libsvn_delta
    libsvn_subr
  )
  target_compile_definitions(libsvn_ra_svn PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion SVN Protocol Repository Access Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_ra_svn>"
  )
  if (WIN32)
    target_sources(libsvn_ra_svn PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_ra_svn)
endif()

# Subversion Repository Library
if (TRUE)
  add_library(libsvn_repos
    subversion/libsvn_repos/authz.c
    subversion/libsvn_repos/authz_info.c
    subversion/libsvn_repos/authz_parse.c
    subversion/libsvn_repos/commit.c
    subversion/libsvn_repos/compat.c
    subversion/libsvn_repos/config_file.c
    subversion/libsvn_repos/config_pool.c
    subversion/libsvn_repos/delta.c
    subversion/libsvn_repos/deprecated.c
    subversion/libsvn_repos/dump.c
    subversion/libsvn_repos/dump_editor.c
    subversion/libsvn_repos/fs-wrap.c
    subversion/libsvn_repos/hooks.c
    subversion/libsvn_repos/list.c
    subversion/libsvn_repos/load-fs-vtable.c
    subversion/libsvn_repos/load.c
    subversion/libsvn_repos/log.c
    subversion/libsvn_repos/node_tree.c
    subversion/libsvn_repos/notify.c
    subversion/libsvn_repos/replay.c
    subversion/libsvn_repos/reporter.c
    subversion/libsvn_repos/repos.c
    subversion/libsvn_repos/rev_hunt.c
  )
  target_exports(libsvn_repos
    subversion/include/svn_repos.h
    subversion/include/private/svn_repos_private.h
    subversion/include/../libsvn_repos/authz.h
  )
  set_target_properties(libsvn_repos PROPERTIES OUTPUT_NAME "svn_repos-1")
  set_target_properties(libsvn_repos PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_repos PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_repos PUBLIC
    external-apr
  )
  target_link_libraries(libsvn_repos PRIVATE
    libsvn_fs
    libsvn_delta
    libsvn_subr
  )
  target_compile_definitions(libsvn_repos PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Repository Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_repos>"
  )
  if (WIN32)
    target_sources(libsvn_repos PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_repos)
endif()

# Subversion General Utility Library
if (TRUE)
  add_library(libsvn_subr
    subversion/libsvn_subr/adler32.c
    subversion/libsvn_subr/apr_escape.c
    subversion/libsvn_subr/atomic.c
    subversion/libsvn_subr/auth.c
    subversion/libsvn_subr/base64.c
    subversion/libsvn_subr/bit_array.c
    subversion/libsvn_subr/cache-inprocess.c
    subversion/libsvn_subr/cache-membuffer.c
    subversion/libsvn_subr/cache-memcache.c
    subversion/libsvn_subr/cache-null.c
    subversion/libsvn_subr/cache.c
    subversion/libsvn_subr/cache_config.c
    subversion/libsvn_subr/checksum.c
    subversion/libsvn_subr/cmdline.c
    subversion/libsvn_subr/cmdline_editor.c
    subversion/libsvn_subr/compat.c
    subversion/libsvn_subr/compress_lz4.c
    subversion/libsvn_subr/compress_zlib.c
    subversion/libsvn_subr/config.c
    subversion/libsvn_subr/config_auth.c
    subversion/libsvn_subr/config_file.c
    subversion/libsvn_subr/config_win.c
    subversion/libsvn_subr/crypto.c
    subversion/libsvn_subr/ctype.c
    subversion/libsvn_subr/date.c
    subversion/libsvn_subr/debug.c
    subversion/libsvn_subr/deprecated.c
    subversion/libsvn_subr/dirent_uri.c
    subversion/libsvn_subr/dso.c
    subversion/libsvn_subr/encode.c
    subversion/libsvn_subr/eol.c
    subversion/libsvn_subr/error.c
    subversion/libsvn_subr/fnv1a.c
    subversion/libsvn_subr/gpg_agent.c
    subversion/libsvn_subr/hash.c
    subversion/libsvn_subr/io.c
    subversion/libsvn_subr/iter.c
    subversion/libsvn_subr/lock.c
    subversion/libsvn_subr/log.c
    subversion/libsvn_subr/lz4/lz4.c
    subversion/libsvn_subr/macos_keychain.c
    subversion/libsvn_subr/magic.c
    subversion/libsvn_subr/md5.c
    subversion/libsvn_subr/mergeinfo.c
    subversion/libsvn_subr/mutex.c
    subversion/libsvn_subr/nls.c
    subversion/libsvn_subr/object_pool.c
    subversion/libsvn_subr/opt.c
    subversion/libsvn_subr/opt_revision.c
    subversion/libsvn_subr/opt_subcommand.c
    subversion/libsvn_subr/packed_data.c
    subversion/libsvn_subr/path.c
    subversion/libsvn_subr/pool.c
    subversion/libsvn_subr/prefix_string.c
    subversion/libsvn_subr/prompt.c
    subversion/libsvn_subr/properties.c
    subversion/libsvn_subr/quoprint.c
    subversion/libsvn_subr/root_pools.c
    subversion/libsvn_subr/simple_providers.c
    subversion/libsvn_subr/skel.c
    subversion/libsvn_subr/sorts.c
    subversion/libsvn_subr/spillbuf.c
    subversion/libsvn_subr/sqlite.c
    subversion/libsvn_subr/sqlite3wrapper.c
    subversion/libsvn_subr/ssl_client_cert_providers.c
    subversion/libsvn_subr/ssl_client_cert_pw_providers.c
    subversion/libsvn_subr/ssl_server_trust_providers.c
    subversion/libsvn_subr/stream.c
    subversion/libsvn_subr/string.c
    subversion/libsvn_subr/subst.c
    subversion/libsvn_subr/sysinfo.c
    subversion/libsvn_subr/target.c
    subversion/libsvn_subr/task.c
    subversion/libsvn_subr/temp_serializer.c
    subversion/libsvn_subr/thread_cond.c
    subversion/libsvn_subr/time.c
    subversion/libsvn_subr/token.c
    subversion/libsvn_subr/types.c
    subversion/libsvn_subr/user.c
    subversion/libsvn_subr/username_providers.c
    subversion/libsvn_subr/utf.c
    subversion/libsvn_subr/utf8proc.c
    subversion/libsvn_subr/utf_validate.c
    subversion/libsvn_subr/utf_width.c
    subversion/libsvn_subr/validate.c
    subversion/libsvn_subr/version.c
    subversion/libsvn_subr/waitable_counter.c
    subversion/libsvn_subr/win32_crashrpt.c
    subversion/libsvn_subr/win32_crypto.c
    subversion/libsvn_subr/win32_xlate.c
    subversion/libsvn_subr/x509info.c
    subversion/libsvn_subr/x509parse.c
    subversion/libsvn_subr/xml.c
    subversion/libsvn_subr/xml_escape.c
    subversion/libsvn_subr/xml_stream.c
  )
  target_exports(libsvn_subr
    subversion/include/svn_auth.h
    subversion/include/svn_base64.h
    subversion/include/svn_cache_config.h
    subversion/include/svn_checksum.h
    subversion/include/svn_cmdline.h
    subversion/include/svn_compat.h
    subversion/include/svn_config.h
    subversion/include/svn_ctype.h
    subversion/include/svn_dirent_uri.h
    subversion/include/svn_dso.h
    subversion/include/svn_error.h
    subversion/include/svn_hash.h
    subversion/include/svn_io.h
    subversion/include/svn_iter.h
    subversion/include/svn_md5.h
    subversion/include/svn_mergeinfo.h
    subversion/include/svn_nls.h
    subversion/include/svn_opt.h
    subversion/include/svn_path.h
    subversion/include/svn_pools.h
    subversion/include/svn_props.h
    subversion/include/svn_quoprint.h
    subversion/include/svn_sorts.h
    subversion/include/svn_string.h
    subversion/include/svn_subst.h
    subversion/include/svn_time.h
    subversion/include/svn_types.h
    subversion/include/svn_user.h
    subversion/include/svn_utf.h
    subversion/include/svn_version.h
    subversion/include/svn_xml.h
    subversion/include/svn_x509.h
    subversion/include/private/svn_atomic.h
    subversion/include/private/svn_cache.h
    subversion/include/private/svn_cmdline_private.h
    subversion/include/private/svn_debug.h
    subversion/include/private/svn_error_private.h
    subversion/include/private/svn_fspath.h
    subversion/include/private/svn_log.h
    subversion/include/private/svn_mergeinfo_private.h
    subversion/include/private/svn_opt_private.h
    subversion/include/private/svn_skel.h
    subversion/include/private/svn_sqlite.h
    subversion/include/private/svn_utf_private.h
    subversion/include/private/svn_eol_private.h
    subversion/include/private/svn_token.h
    subversion/include/private/svn_adler32.h
    subversion/include/private/svn_temp_serializer.h
    subversion/include/private/svn_io_private.h
    subversion/include/private/svn_sorts_private.h
    subversion/include/private/svn_auth_private.h
    subversion/include/private/svn_string_private.h
    subversion/include/private/svn_magic.h
    subversion/include/private/svn_subr_private.h
    subversion/include/private/svn_mutex.h
    subversion/include/private/svn_task.h
    subversion/include/private/svn_thread_cond.h
    subversion/include/private/svn_waitable_counter.h
    subversion/include/private/svn_packed_data.h
    subversion/include/private/svn_object_pool.h
    subversion/include/private/svn_cert.h
    subversion/include/private/svn_config_private.h
    subversion/include/private/svn_dirent_uri_private.h
    subversion/include/private/svn_xml_private.h
    subversion/include/../libsvn_subr/crypto.h
  )
  set_target_properties(libsvn_subr PROPERTIES OUTPUT_NAME "svn_subr-1")
  set_target_properties(libsvn_subr PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_subr PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_subr PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_subr PRIVATE
    external-xml
    external-zlib
    external-sqlite
    external-intl
    external-lz4
    external-utf8proc
  )
  if (WIN32)
    target_link_libraries(libsvn_subr PRIVATE kernel32.lib advapi32.lib shfolder.lib ole32.lib crypt32.lib version.lib ws2_32.lib)
  endif()
  target_compile_definitions(libsvn_subr PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion General Utility Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_subr>"
  )
  if (WIN32)
    target_sources(libsvn_subr PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_subr)
endif()

# libsvn_swig_perl
if (SVN_ENABLE_SWIG_PERL)
  add_library(libsvn_swig_perl
    subversion/bindings/swig/perl/libsvn_swig_perl/swigutil_pl.c
  )
  target_exports(libsvn_swig_perl
    subversion/include/../bindings/swig/perl/libsvn_swig_perl/swigutil_pl.h
  )
  set_target_properties(libsvn_swig_perl PROPERTIES OUTPUT_NAME "svn_swig_perl-1")
  set_target_properties(libsvn_swig_perl PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_swig_perl PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_swig_perl PUBLIC
    external-apr
  )
  target_link_libraries(libsvn_swig_perl PRIVATE
    libsvn_delta
    libsvn_subr
    external-perl
    external-swig
  )
  target_compile_definitions(libsvn_swig_perl PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_swig_perl>"
  )
  if (WIN32)
    target_sources(libsvn_swig_perl PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_swig_perl)
endif()

# Subversion utility library for Python bindings
if (SVN_ENABLE_SWIG_PYTHON)
  add_library(libsvn_swig_py
    subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
  )
  target_exports(libsvn_swig_py
    subversion/include/../bindings/swig/python/libsvn_swig_py/swigutil_py.h
  )
  set_target_properties(libsvn_swig_py PROPERTIES OUTPUT_NAME "svn_swig_py-1")
  set_target_properties(libsvn_swig_py PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_swig_py PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_swig_py PUBLIC
    external-apr
  )
  target_link_libraries(libsvn_swig_py PRIVATE
    libsvn_client
    libsvn_wc
    libsvn_ra
    libsvn_delta
    libsvn_subr
    external-python
    external-swig
  )
  target_compile_definitions(libsvn_swig_py PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion utility library for Python bindings"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_swig_py>"
  )
  if (WIN32)
    target_sources(libsvn_swig_py PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_swig_py)
endif()

# libsvn_swig_ruby
if (SVN_ENABLE_SWIG_RUBY)
  add_library(libsvn_swig_ruby
    subversion/bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.c
  )
  target_exports(libsvn_swig_ruby
    subversion/include/../bindings/swig/ruby/libsvn_swig_ruby/swigutil_rb.h
  )
  set_target_properties(libsvn_swig_ruby PROPERTIES OUTPUT_NAME "svn_swig_ruby-1")
  set_target_properties(libsvn_swig_ruby PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_swig_ruby PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_swig_ruby PUBLIC
    external-apr
  )
  target_link_libraries(libsvn_swig_ruby PRIVATE
    libsvn_client
    libsvn_wc
    libsvn_delta
    libsvn_subr
    external-ruby
    external-swig
  )
  target_compile_definitions(libsvn_swig_ruby PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_swig_ruby>"
  )
  if (WIN32)
    target_sources(libsvn_swig_ruby PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_swig_ruby)
endif()

# libsvn_test
if (TRUE)
  add_library(libsvn_test STATIC
    subversion/tests/svn_test_fs.c
    subversion/tests/svn_test_main.c
  )
  set_target_properties(libsvn_test PROPERTIES OUTPUT_NAME "svn_test-1")
  set_target_properties(libsvn_test PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_test PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_test PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_test PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_wc
    libsvn_subr
  )
  target_compile_definitions(libsvn_test PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_test>"
  )
  if (WIN32)
    target_sources(libsvn_test PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_test)
endif()

# Subversion Working Copy Library
if (TRUE)
  add_library(libsvn_wc
    subversion/libsvn_wc/adm_crawler.c
    subversion/libsvn_wc/adm_files.c
    subversion/libsvn_wc/adm_ops.c
    subversion/libsvn_wc/ambient_depth_filter_editor.c
    subversion/libsvn_wc/cleanup.c
    subversion/libsvn_wc/conflicts.c
    subversion/libsvn_wc/context.c
    subversion/libsvn_wc/copy.c
    subversion/libsvn_wc/crop.c
    subversion/libsvn_wc/delete.c
    subversion/libsvn_wc/deprecated.c
    subversion/libsvn_wc/diff_editor.c
    subversion/libsvn_wc/diff_local.c
    subversion/libsvn_wc/entries.c
    subversion/libsvn_wc/externals.c
    subversion/libsvn_wc/info.c
    subversion/libsvn_wc/lock.c
    subversion/libsvn_wc/merge.c
    subversion/libsvn_wc/node.c
    subversion/libsvn_wc/old-and-busted.c
    subversion/libsvn_wc/props.c
    subversion/libsvn_wc/questions.c
    subversion/libsvn_wc/relocate.c
    subversion/libsvn_wc/revert.c
    subversion/libsvn_wc/revision_status.c
    subversion/libsvn_wc/status.c
    subversion/libsvn_wc/textbase.c
    subversion/libsvn_wc/translate.c
    subversion/libsvn_wc/tree_conflicts.c
    subversion/libsvn_wc/update_editor.c
    subversion/libsvn_wc/upgrade.c
    subversion/libsvn_wc/util.c
    subversion/libsvn_wc/wc_db.c
    subversion/libsvn_wc/wc_db_pristine.c
    subversion/libsvn_wc/wc_db_textbase.c
    subversion/libsvn_wc/wc_db_update_move.c
    subversion/libsvn_wc/wc_db_util.c
    subversion/libsvn_wc/wc_db_wcroot.c
    subversion/libsvn_wc/wcroot_anchor.c
    subversion/libsvn_wc/working_file_writer.c
    subversion/libsvn_wc/workqueue.c
  )
  target_exports(libsvn_wc
    subversion/include/svn_wc.h
    subversion/include/private/svn_wc_private.h
    subversion/include/../libsvn_wc/conflicts.h
    subversion/include/../libsvn_wc/lock.h
    subversion/include/../libsvn_wc/token-map.h
    subversion/include/../libsvn_wc/tree_conflicts.h
    subversion/include/../libsvn_wc/wc_db_private.h
    subversion/include/../libsvn_wc/wc_db.h
    subversion/include/../libsvn_wc/wc-queries.h
    subversion/include/../libsvn_wc/wc.h
    subversion/include/../libsvn_wc/workqueue.h
  )
  set_target_properties(libsvn_wc PROPERTIES OUTPUT_NAME "svn_wc-1")
  set_target_properties(libsvn_wc PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvn_wc PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvn_wc PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvn_wc PRIVATE
    libsvn_delta
    libsvn_diff
    libsvn_subr
  )
  target_compile_definitions(libsvn_wc PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Working Copy Library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvn_wc>"
  )
  if (WIN32)
    target_sources(libsvn_wc PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvn_wc)
endif()

# Subversion C++ bindings
if (SVN_ENABLE_SVNXX)
  add_library(libsvnxx STATIC
    subversion/bindings/cxx/src/aprwrap/impl.cpp
    subversion/bindings/cxx/src/client_context.cpp
    subversion/bindings/cxx/src/client_status.cpp
    subversion/bindings/cxx/src/debug.cpp
    subversion/bindings/cxx/src/depth.cpp
    subversion/bindings/cxx/src/exception.cpp
    subversion/bindings/cxx/src/future.cpp
    subversion/bindings/cxx/src/init.cpp
    subversion/bindings/cxx/src/revision.cpp
  )
  set_target_properties(libsvnxx PROPERTIES OUTPUT_NAME "svnxx-1")
  set_target_properties(libsvnxx PROPERTIES SOVERSION "${SVN_SOVERSION}" VERSION "${SVN_SOVERSION}.0.0")
  target_include_directories(libsvnxx PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(libsvnxx PUBLIC
    external-aprutil
    external-apr
  )
  target_link_libraries(libsvnxx PRIVATE
    libsvn_repos
    libsvn_client
    libsvn_wc
    libsvn_ra
    libsvn_delta
    libsvn_diff
    libsvn_subr
    libsvn_fs
  )
  target_compile_definitions(libsvnxx PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion C++ bindings"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:libsvnxx>"
  )
  if (WIN32)
    target_sources(libsvnxx PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS libsvnxx)
endif()

# lock-helper
if (SVN_ENABLE_TESTS)
  add_executable(lock-helper
    subversion/tests/cmdline/lock-helper.c
  )
  if (WIN32)
    target_sources(lock-helper PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(lock-helper PRIVATE
    libsvn_fs
    libsvn_subr
    external-apr
  )
  target_compile_definitions(lock-helper PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:lock-helper>"
  )
  if (WIN32)
    target_sources(lock-helper PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test locks in libsvn_fs
if (SVN_ENABLE_TESTS)
  add_executable(locks-test
    subversion/tests/libsvn_fs/locks-test.c
  )
  add_test(
    NAME libsvn_fs.locks-test
    COMMAND locks-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_fs
    WORKING_DIRECTORY $<TARGET_FILE_DIR:locks-test>
  )
  set_tests_properties(libsvn_fs.locks-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:locks-test>)
  target_link_libraries(locks-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(locks-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test locks in libsvn_fs"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:locks-test>"
  )
  if (WIN32)
    target_sources(locks-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test mergeinfo library
if (SVN_ENABLE_TESTS)
  add_executable(mergeinfo-test
    subversion/tests/libsvn_subr/mergeinfo-test.c
  )
  add_test(
    NAME libsvn_subr.mergeinfo-test
    COMMAND mergeinfo-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:mergeinfo-test>
  )
  set_tests_properties(libsvn_subr.mergeinfo-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:mergeinfo-test>)
  target_link_libraries(mergeinfo-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(mergeinfo-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test mergeinfo library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:mergeinfo-test>"
  )
  if (WIN32)
    target_sources(mergeinfo-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Subversion path-based authorization module for Apache
if (SVN_ENABLE_APACHE_MODULES)
  add_library(mod_authz_svn
    subversion/mod_authz_svn/mod_authz_svn.c
  )
  set_target_properties(mod_authz_svn PROPERTIES OUTPUT_NAME "mod_authz_svn")
  set_target_properties(mod_authz_svn PROPERTIES PREFIX "" SUFFIX ".so")
  target_include_directories(mod_authz_svn PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(mod_authz_svn PUBLIC
    external-apr
    external-aprutil
  )
  target_link_libraries(mod_authz_svn PRIVATE
    libsvn_repos
    libsvn_subr
    external-libhttpd
    mod_dav_svn
  )
  target_compile_definitions(mod_authz_svn PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion path-based authorization module for Apache"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:mod_authz_svn>"
  )
  if (WIN32)
    target_sources(mod_authz_svn PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS mod_authz_svn)
endif()

# Subversion plug-in for the Apache DAV module
if (SVN_ENABLE_APACHE_MODULES)
  add_library(mod_dav_svn
    subversion/mod_dav_svn/activity.c
    subversion/mod_dav_svn/authz.c
    subversion/mod_dav_svn/deadprops.c
    subversion/mod_dav_svn/liveprops.c
    subversion/mod_dav_svn/lock.c
    subversion/mod_dav_svn/merge.c
    subversion/mod_dav_svn/mirror.c
    subversion/mod_dav_svn/mod_dav_svn.c
    subversion/mod_dav_svn/posts/create_txn.c
    subversion/mod_dav_svn/reports/dated-rev.c
    subversion/mod_dav_svn/reports/deleted-rev.c
    subversion/mod_dav_svn/reports/file-revs.c
    subversion/mod_dav_svn/reports/get-location-segments.c
    subversion/mod_dav_svn/reports/get-locations.c
    subversion/mod_dav_svn/reports/get-locks.c
    subversion/mod_dav_svn/reports/inherited-props.c
    subversion/mod_dav_svn/reports/list.c
    subversion/mod_dav_svn/reports/log.c
    subversion/mod_dav_svn/reports/mergeinfo.c
    subversion/mod_dav_svn/reports/replay.c
    subversion/mod_dav_svn/reports/update.c
    subversion/mod_dav_svn/repos.c
    subversion/mod_dav_svn/status.c
    subversion/mod_dav_svn/util.c
    subversion/mod_dav_svn/version.c
  )
  set_target_properties(mod_dav_svn PROPERTIES OUTPUT_NAME "mod_dav_svn")
  set_target_properties(mod_dav_svn PROPERTIES PREFIX "" SUFFIX ".so")
  target_include_directories(mod_dav_svn PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(mod_dav_svn PUBLIC
    external-apr
    external-aprutil
  )
  target_link_libraries(mod_dav_svn PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-libhttpd
    external-mod_dav
  )
  target_compile_definitions(mod_dav_svn PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion plug-in for the Apache DAV module"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:mod_dav_svn>"
  )
  if (WIN32)
    target_sources(mod_dav_svn PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS mod_dav_svn)
endif()

# Apache Httpd module to block certain kinds of Apache Subversion requests
if (SVN_ENABLE_APACHE_MODULES)
  add_library(mod_dontdothat
    tools/server-side/mod_dontdothat/mod_dontdothat.c
  )
  set_target_properties(mod_dontdothat PROPERTIES OUTPUT_NAME "mod_dontdothat")
  set_target_properties(mod_dontdothat PROPERTIES PREFIX "" SUFFIX ".so")
  target_include_directories(mod_dontdothat PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/subversion/include"
  )
  target_link_libraries(mod_dontdothat PUBLIC
    external-apr
    external-aprutil
  )
  target_link_libraries(mod_dontdothat PRIVATE
    libsvn_subr
    external-libhttpd
    mod_dav_svn
  )
  target_compile_definitions(mod_dontdothat PRIVATE
    "SVN_FILE_DESCRIPTION=Apache Httpd module to block certain kinds of Apache Subversion requests"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:mod_dontdothat>"
  )
  if (WIN32)
    target_sources(mod_dontdothat PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS mod_dontdothat)
endif()

# Test Multi Command Context
if (SVN_ENABLE_TESTS)
  add_executable(mtcc-test
    subversion/tests/libsvn_client/mtcc-test.c
  )
  add_test(
    NAME libsvn_client.mtcc-test
    COMMAND mtcc-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_client
    WORKING_DIRECTORY $<TARGET_FILE_DIR:mtcc-test>
  )
  set_tests_properties(libsvn_client.mtcc-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:mtcc-test>)
  target_link_libraries(mtcc-test PRIVATE
    libsvn_test
    libsvn_client
    libsvn_wc
    libsvn_repos
    libsvn_ra
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(mtcc-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test Multi Command Context"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:mtcc-test>"
  )
  if (WIN32)
    target_sources(mtcc-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test layered tree changes
if (SVN_ENABLE_TESTS)
  add_executable(op-depth-test
    subversion/tests/libsvn_wc/op-depth-test.c
    subversion/tests/libsvn_wc/utils.c
  )
  add_test(
    NAME libsvn_wc.op-depth-test
    COMMAND op-depth-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_wc
    WORKING_DIRECTORY $<TARGET_FILE_DIR:op-depth-test>
  )
  set_tests_properties(libsvn_wc.op-depth-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:op-depth-test>)
  target_link_libraries(op-depth-test PRIVATE
    libsvn_client
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(op-depth-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test layered tree changes"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:op-depth-test>"
  )
  if (WIN32)
    target_sources(op-depth-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test options library
if (SVN_ENABLE_TESTS)
  add_executable(opt-test
    subversion/tests/libsvn_subr/opt-test.c
  )
  add_test(
    NAME libsvn_subr.opt-test
    COMMAND opt-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:opt-test>
  )
  set_tests_properties(libsvn_subr.opt-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:opt-test>)
  target_link_libraries(opt-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(opt-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test options library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:opt-test>"
  )
  if (WIN32)
    target_sources(opt-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test path library
if (SVN_ENABLE_TESTS)
  add_executable(packed-data-test
    subversion/tests/libsvn_subr/packed-data-test.c
  )
  add_test(
    NAME libsvn_subr.packed-data-test
    COMMAND packed-data-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:packed-data-test>
  )
  set_tests_properties(libsvn_subr.packed-data-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:packed-data-test>)
  target_link_libraries(packed-data-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(packed-data-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test path library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:packed-data-test>"
  )
  if (WIN32)
    target_sources(packed-data-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test unidiff parsing
if (SVN_ENABLE_TESTS)
  add_executable(parse-diff-test
    subversion/tests/libsvn_diff/parse-diff-test.c
  )
  add_test(
    NAME libsvn_diff.parse-diff-test
    COMMAND parse-diff-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_diff
    WORKING_DIRECTORY $<TARGET_FILE_DIR:parse-diff-test>
  )
  set_tests_properties(libsvn_diff.parse-diff-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:parse-diff-test>)
  target_link_libraries(parse-diff-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_diff
    libsvn_subr
    external-apr
  )
  target_compile_definitions(parse-diff-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test unidiff parsing"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:parse-diff-test>"
  )
  if (WIN32)
    target_sources(parse-diff-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test path library
if (SVN_ENABLE_TESTS)
  add_executable(path-test
    subversion/tests/libsvn_subr/path-test.c
  )
  add_test(
    NAME libsvn_subr.path-test
    COMMAND path-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:path-test>
  )
  set_tests_properties(libsvn_subr.path-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:path-test>)
  target_link_libraries(path-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(path-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test path library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:path-test>"
  )
  if (WIN32)
    target_sources(path-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Subversion client library bindings for Perl
if (SVN_ENABLE_SWIG_PERL)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(perl_client
    LANGUAGE perl
    SOURCES subversion/bindings/swig/svn_client.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PerlLibs/TODO"
  )
  set_target_properties(perl_client PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME perl_client
  )
  target_link_libraries(perl_client PRIVATE
    external-apr
    libsvn_swig_perl
    libsvn_client
    libsvn_subr
    external-perl
  )
endif()

# Subversion core library bindings for Perl
if (SVN_ENABLE_SWIG_PERL)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(perl_core
    LANGUAGE perl
    SOURCES subversion/bindings/swig/core.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PerlLibs/TODO"
  )
  set_target_properties(perl_core PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME perl_core
  )
  target_link_libraries(perl_core PRIVATE
    external-apr
    libsvn_swig_perl
    libsvn_diff
    libsvn_subr
    external-perl
  )
endif()

# Subversion delta library bindings for Perl
if (SVN_ENABLE_SWIG_PERL)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(perl_delta
    LANGUAGE perl
    SOURCES subversion/bindings/swig/svn_delta.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PerlLibs/TODO"
  )
  set_target_properties(perl_delta PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME perl_delta
  )
  target_link_libraries(perl_delta PRIVATE
    external-apr
    libsvn_swig_perl
    libsvn_delta
    libsvn_subr
    external-perl
  )
endif()

# Subversion diff library bindings for Perl
if (SVN_ENABLE_SWIG_PERL)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(perl_diff
    LANGUAGE perl
    SOURCES subversion/bindings/swig/svn_diff.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PerlLibs/TODO"
  )
  set_target_properties(perl_diff PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME perl_diff
  )
  target_link_libraries(perl_diff PRIVATE
    external-apr
    libsvn_swig_perl
    libsvn_diff
    libsvn_subr
    external-perl
  )
endif()

# Subversion FS library bindings for Perl
if (SVN_ENABLE_SWIG_PERL)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(perl_fs
    LANGUAGE perl
    SOURCES subversion/bindings/swig/svn_fs.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PerlLibs/TODO"
  )
  set_target_properties(perl_fs PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME perl_fs
  )
  target_link_libraries(perl_fs PRIVATE
    external-apr
    libsvn_swig_perl
    libsvn_fs
    libsvn_subr
    external-perl
  )
endif()

# Subversion RA library bindings for Perl
if (SVN_ENABLE_SWIG_PERL)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(perl_ra
    LANGUAGE perl
    SOURCES subversion/bindings/swig/svn_ra.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PerlLibs/TODO"
  )
  set_target_properties(perl_ra PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME perl_ra
  )
  target_link_libraries(perl_ra PRIVATE
    external-apr
    libsvn_swig_perl
    libsvn_ra
    libsvn_subr
    external-perl
  )
endif()

# Subversion repository library bindings for Perl
if (SVN_ENABLE_SWIG_PERL)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(perl_repos
    LANGUAGE perl
    SOURCES subversion/bindings/swig/svn_repos.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PerlLibs/TODO"
  )
  set_target_properties(perl_repos PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME perl_repos
  )
  target_link_libraries(perl_repos PRIVATE
    external-apr
    libsvn_swig_perl
    libsvn_repos
    libsvn_subr
    external-perl
  )
endif()

# Subversion WC library bindings for Perl
if (SVN_ENABLE_SWIG_PERL)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(perl_wc
    LANGUAGE perl
    SOURCES subversion/bindings/swig/svn_wc.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PerlLibs/TODO"
  )
  set_target_properties(perl_wc PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME perl_wc
  )
  target_link_libraries(perl_wc PRIVATE
    external-apr
    libsvn_swig_perl
    libsvn_wc
    libsvn_subr
    external-perl
  )
endif()

# Test path library
if (SVN_ENABLE_TESTS)
  add_executable(prefix-string-test
    subversion/tests/libsvn_subr/prefix-string-test.c
  )
  add_test(
    NAME libsvn_subr.prefix-string-test
    COMMAND prefix-string-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:prefix-string-test>
  )
  set_tests_properties(libsvn_subr.prefix-string-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:prefix-string-test>)
  target_link_libraries(prefix-string-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(prefix-string-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test path library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:prefix-string-test>"
  )
  if (WIN32)
    target_sources(prefix-string-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test path library
if (SVN_ENABLE_TESTS)
  add_executable(priority-queue-test
    subversion/tests/libsvn_subr/priority-queue-test.c
  )
  add_test(
    NAME libsvn_subr.priority-queue-test
    COMMAND priority-queue-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:priority-queue-test>
  )
  set_tests_properties(libsvn_subr.priority-queue-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:priority-queue-test>)
  target_link_libraries(priority-queue-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(priority-queue-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test path library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:priority-queue-test>"
  )
  if (WIN32)
    target_sources(priority-queue-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test the wc-ng pristine text storage subsystem
if (SVN_ENABLE_TESTS)
  add_executable(pristine-store-test
    subversion/tests/libsvn_wc/pristine-store-test.c
    subversion/tests/libsvn_wc/utils.c
  )
  add_test(
    NAME libsvn_wc.pristine-store-test
    COMMAND pristine-store-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_wc
    WORKING_DIRECTORY $<TARGET_FILE_DIR:pristine-store-test>
  )
  set_tests_properties(libsvn_wc.pristine-store-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:pristine-store-test>)
  target_link_libraries(pristine-store-test PRIVATE
    libsvn_client
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(pristine-store-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test the wc-ng pristine text storage subsystem"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:pristine-store-test>"
  )
  if (WIN32)
    target_sources(pristine-store-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Subversion client library bindings for Python
if (SVN_ENABLE_SWIG_PYTHON)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(python_client
    LANGUAGE python
    SOURCES subversion/bindings/swig/svn_client.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PythonPackages/libsvn"
  )
  set_target_properties(python_client PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME client
  )
  set_target_properties(python_client PROPERTIES
    SWIG_COMPILE_OPTIONS "-nofastunpack"
  )
  target_link_libraries(python_client PRIVATE
    external-apr
    libsvn_swig_py
    libsvn_client
    libsvn_subr
    external-python
  )
endif()

# Subversion core library bindings for Python
if (SVN_ENABLE_SWIG_PYTHON)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(python_core
    LANGUAGE python
    SOURCES subversion/bindings/swig/core.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PythonPackages/libsvn"
  )
  set_target_properties(python_core PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME core
  )
  set_target_properties(python_core PROPERTIES
    SWIG_COMPILE_OPTIONS "-nofastunpack"
  )
  target_link_libraries(python_core PRIVATE
    external-apr
    libsvn_swig_py
    libsvn_diff
    libsvn_subr
    external-python
  )
endif()

# Subversion delta library bindings for Python
if (SVN_ENABLE_SWIG_PYTHON)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(python_delta
    LANGUAGE python
    SOURCES subversion/bindings/swig/svn_delta.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PythonPackages/libsvn"
  )
  set_target_properties(python_delta PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME delta
  )
  set_target_properties(python_delta PROPERTIES
    SWIG_COMPILE_OPTIONS "-nofastunpack"
  )
  target_link_libraries(python_delta PRIVATE
    external-apr
    libsvn_swig_py
    libsvn_delta
    libsvn_subr
    external-python
  )
endif()

# Subversion diff library bindings for Python
if (SVN_ENABLE_SWIG_PYTHON)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(python_diff
    LANGUAGE python
    SOURCES subversion/bindings/swig/svn_diff.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PythonPackages/libsvn"
  )
  set_target_properties(python_diff PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME diff
  )
  set_target_properties(python_diff PROPERTIES
    SWIG_COMPILE_OPTIONS "-nofastunpack"
  )
  target_link_libraries(python_diff PRIVATE
    external-apr
    libsvn_swig_py
    libsvn_diff
    libsvn_subr
    external-python
  )
endif()

# Subversion FS library bindings for Python
if (SVN_ENABLE_SWIG_PYTHON)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(python_fs
    LANGUAGE python
    SOURCES subversion/bindings/swig/svn_fs.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PythonPackages/libsvn"
  )
  set_target_properties(python_fs PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME fs
  )
  set_target_properties(python_fs PROPERTIES
    SWIG_COMPILE_OPTIONS "-nofastunpack"
  )
  target_link_libraries(python_fs PRIVATE
    external-apr
    libsvn_swig_py
    libsvn_fs
    libsvn_subr
    external-python
  )
endif()

# Subversion RA library bindings for Python
if (SVN_ENABLE_SWIG_PYTHON)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(python_ra
    LANGUAGE python
    SOURCES subversion/bindings/swig/svn_ra.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PythonPackages/libsvn"
  )
  set_target_properties(python_ra PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME ra
  )
  set_target_properties(python_ra PROPERTIES
    SWIG_COMPILE_OPTIONS "-nofastunpack"
  )
  target_link_libraries(python_ra PRIVATE
    external-apr
    libsvn_swig_py
    libsvn_ra
    libsvn_subr
    external-python
  )
endif()

# Subversion repository library bindings for Python
if (SVN_ENABLE_SWIG_PYTHON)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(python_repos
    LANGUAGE python
    SOURCES subversion/bindings/swig/svn_repos.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PythonPackages/libsvn"
  )
  set_target_properties(python_repos PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME repos
  )
  set_target_properties(python_repos PROPERTIES
    SWIG_COMPILE_OPTIONS "-nofastunpack"
  )
  target_link_libraries(python_repos PRIVATE
    external-apr
    libsvn_swig_py
    libsvn_repos
    libsvn_subr
    external-python
  )
endif()

# Subversion WC library bindings for Python
if (SVN_ENABLE_SWIG_PYTHON)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(python_wc
    LANGUAGE python
    SOURCES subversion/bindings/swig/svn_wc.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/PythonPackages/libsvn"
  )
  set_target_properties(python_wc PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME wc
  )
  set_target_properties(python_wc PROPERTIES
    SWIG_COMPILE_OPTIONS "-nofastunpack"
  )
  target_link_libraries(python_wc PRIVATE
    external-apr
    libsvn_swig_py
    libsvn_wc
    libsvn_subr
    external-python
  )
endif()

# Test a few things in libsvn_ra_local
if (SVN_ENABLE_TESTS AND SVN_ENABLE_RA_LOCAL)
  add_executable(ra-local-test
    subversion/tests/libsvn_ra_local/ra-local-test.c
  )
  add_test(
    NAME libsvn_ra_local.ra-local-test
    COMMAND ra-local-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_ra_local
    WORKING_DIRECTORY $<TARGET_FILE_DIR:ra-local-test>
  )
  set_tests_properties(libsvn_ra_local.ra-local-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:ra-local-test>)
  target_link_libraries(ra-local-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_ra_local
    libsvn_ra
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(ra-local-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test a few things in libsvn_ra_local"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:ra-local-test>"
  )
  if (WIN32)
    target_sources(ra-local-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test a few things in libsvn_ra
if (SVN_ENABLE_TESTS AND SVN_ENABLE_RA_SVN)
  add_executable(ra-test
    subversion/tests/libsvn_ra/ra-test.c
  )
  add_test(
    NAME libsvn_ra.ra-test
    COMMAND ra-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_ra
    WORKING_DIRECTORY $<TARGET_FILE_DIR:ra-test>
  )
  set_tests_properties(libsvn_ra.ra-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:ra-test>)
  target_link_libraries(ra-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_ra
    libsvn_ra_svn
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(ra-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test a few things in libsvn_ra"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:ra-test>"
  )
  if (WIN32)
    target_sources(ra-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Use random data to test delta processing
if (SVN_ENABLE_TESTS)
  add_executable(random-test
    subversion/tests/libsvn_delta/random-test.c
  )
  add_test(
    NAME libsvn_delta.random-test
    COMMAND random-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_delta
    WORKING_DIRECTORY $<TARGET_FILE_DIR:random-test>
  )
  set_tests_properties(libsvn_delta.random-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:random-test>)
  target_link_libraries(random-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(random-test PRIVATE
    "SVN_FILE_DESCRIPTION=Use random data to test delta processing"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:random-test>"
  )
  if (WIN32)
    target_sources(random-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test delta editor in libsvn_repos
if (SVN_ENABLE_TESTS)
  add_executable(repos-test
    subversion/tests/libsvn_repos/dir-delta-editor.c
    subversion/tests/libsvn_repos/repos-test.c
  )
  add_test(
    NAME libsvn_repos.repos-test
    COMMAND repos-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_repos
    WORKING_DIRECTORY $<TARGET_FILE_DIR:repos-test>
  )
  set_tests_properties(libsvn_repos.repos-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:repos-test>)
  target_link_libraries(repos-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(repos-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test delta editor in libsvn_repos"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:repos-test>"
  )
  if (WIN32)
    target_sources(repos-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test revision library
if (SVN_ENABLE_TESTS)
  add_executable(revision-test
    subversion/tests/libsvn_subr/revision-test.c
  )
  add_test(
    NAME libsvn_subr.revision-test
    COMMAND revision-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:revision-test>
  )
  set_tests_properties(libsvn_subr.revision-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:revision-test>)
  target_link_libraries(revision-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(revision-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test revision library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:revision-test>"
  )
  if (WIN32)
    target_sources(revision-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test time functions
if (SVN_ENABLE_TESTS)
  add_executable(root-pools-test
    subversion/tests/libsvn_subr/root-pools-test.c
  )
  add_test(
    NAME libsvn_subr.root-pools-test
    COMMAND root-pools-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:root-pools-test>
  )
  set_tests_properties(libsvn_subr.root-pools-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:root-pools-test>)
  target_link_libraries(root-pools-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(root-pools-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test time functions"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:root-pools-test>"
  )
  if (WIN32)
    target_sources(root-pools-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Subversion client library bindings for Ruby
if (SVN_ENABLE_SWIG_RUBY)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(ruby_client
    LANGUAGE ruby
    SOURCES subversion/bindings/swig/svn_client.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/site_ruby/TODO"
  )
  set_target_properties(ruby_client PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME ruby_client
  )
  target_link_libraries(ruby_client PRIVATE
    external-apr
    libsvn_swig_ruby
    libsvn_client
    libsvn_subr
    external-ruby
  )
endif()

# Subversion core library bindings for Ruby
if (SVN_ENABLE_SWIG_RUBY)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(ruby_core
    LANGUAGE ruby
    SOURCES subversion/bindings/swig/core.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/site_ruby/TODO"
  )
  set_target_properties(ruby_core PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME ruby_core
  )
  target_link_libraries(ruby_core PRIVATE
    external-apr
    libsvn_swig_ruby
    libsvn_diff
    libsvn_subr
    external-ruby
  )
endif()

# Subversion delta library bindings for Ruby
if (SVN_ENABLE_SWIG_RUBY)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(ruby_delta
    LANGUAGE ruby
    SOURCES subversion/bindings/swig/svn_delta.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/site_ruby/TODO"
  )
  set_target_properties(ruby_delta PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME ruby_delta
  )
  target_link_libraries(ruby_delta PRIVATE
    external-apr
    libsvn_swig_ruby
    libsvn_delta
    libsvn_subr
    external-ruby
  )
endif()

# Subversion diff library bindings for Ruby
if (SVN_ENABLE_SWIG_RUBY)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(ruby_diff
    LANGUAGE ruby
    SOURCES subversion/bindings/swig/svn_diff.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/site_ruby/TODO"
  )
  set_target_properties(ruby_diff PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME ruby_diff
  )
  target_link_libraries(ruby_diff PRIVATE
    external-apr
    libsvn_swig_ruby
    libsvn_diff
    libsvn_subr
    external-ruby
  )
endif()

# Subversion FS library bindings for Ruby
if (SVN_ENABLE_SWIG_RUBY)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(ruby_fs
    LANGUAGE ruby
    SOURCES subversion/bindings/swig/svn_fs.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/site_ruby/TODO"
  )
  set_target_properties(ruby_fs PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME ruby_fs
  )
  target_link_libraries(ruby_fs PRIVATE
    external-apr
    libsvn_swig_ruby
    libsvn_fs
    libsvn_subr
    external-ruby
  )
endif()

# Subversion RA library bindings for Ruby
if (SVN_ENABLE_SWIG_RUBY)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(ruby_ra
    LANGUAGE ruby
    SOURCES subversion/bindings/swig/svn_ra.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/site_ruby/TODO"
  )
  set_target_properties(ruby_ra PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME ruby_ra
  )
  target_link_libraries(ruby_ra PRIVATE
    external-apr
    libsvn_swig_ruby
    libsvn_ra
    libsvn_subr
    external-ruby
  )
endif()

# Subversion repository library bindings for Ruby
if (SVN_ENABLE_SWIG_RUBY)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(ruby_repos
    LANGUAGE ruby
    SOURCES subversion/bindings/swig/svn_repos.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/site_ruby/TODO"
  )
  set_target_properties(ruby_repos PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME ruby_repos
  )
  target_link_libraries(ruby_repos PRIVATE
    external-apr
    libsvn_swig_ruby
    libsvn_repos
    libsvn_subr
    external-ruby
  )
endif()

# Subversion WC library bindings for Ruby
if (SVN_ENABLE_SWIG_RUBY)
  # TODO: Use generator expressions instead of CMAKE_CURRENT_BINARY_DIR?
  swig_add_library(ruby_wc
    LANGUAGE ruby
    SOURCES subversion/bindings/swig/svn_wc.i
    OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/site_ruby/TODO"
  )
  set_target_properties(ruby_wc PROPERTIES
    SWIG_INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    INCLUDE_DIRECTORIES "${SWIG_INCLUDE_DIRECTORIES}"
    OUTPUT_NAME ruby_wc
  )
  target_link_libraries(ruby_wc PRIVATE
    external-apr
    libsvn_swig_ruby
    libsvn_wc
    libsvn_subr
    external-ruby
  )
endif()

# Test skels in libsvn_subr
if (SVN_ENABLE_TESTS)
  add_executable(skel-test
    subversion/tests/libsvn_subr/skel-test.c
  )
  add_test(
    NAME libsvn_subr.skel-test
    COMMAND skel-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:skel-test>
  )
  set_tests_properties(libsvn_subr.skel-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:skel-test>)
  target_link_libraries(skel-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(skel-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test skels in libsvn_subr"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:skel-test>"
  )
  if (WIN32)
    target_sources(skel-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test spillbuf in libsvn_subr
if (SVN_ENABLE_TESTS)
  add_executable(spillbuf-test
    subversion/tests/libsvn_subr/spillbuf-test.c
  )
  add_test(
    NAME libsvn_subr.spillbuf-test
    COMMAND spillbuf-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:spillbuf-test>
  )
  set_tests_properties(libsvn_subr.spillbuf-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:spillbuf-test>)
  target_link_libraries(spillbuf-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(spillbuf-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test spillbuf in libsvn_subr"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:spillbuf-test>"
  )
  if (WIN32)
    target_sources(spillbuf-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test stream library
if (SVN_ENABLE_TESTS)
  add_executable(sqlite-test
    subversion/tests/libsvn_subr/sqlite-test.c
  )
  add_test(
    NAME libsvn_subr.sqlite-test
    COMMAND sqlite-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:sqlite-test>
  )
  set_tests_properties(libsvn_subr.sqlite-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:sqlite-test>)
  target_link_libraries(sqlite-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(sqlite-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test stream library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:sqlite-test>"
  )
  if (WIN32)
    target_sources(sqlite-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test stream library
if (SVN_ENABLE_TESTS)
  add_executable(stream-test
    subversion/tests/libsvn_subr/stream-test.c
  )
  add_test(
    NAME libsvn_subr.stream-test
    COMMAND stream-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:stream-test>
  )
  set_tests_properties(libsvn_subr.stream-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:stream-test>)
  target_link_libraries(stream-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(stream-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test stream library"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:stream-test>"
  )
  if (WIN32)
    target_sources(stream-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test fsfs string tables
if (SVN_ENABLE_TESTS AND SVN_ENABLE_FS_X)
  add_executable(string-table-test
    subversion/tests/libsvn_fs_x/string-table-test.c
  )
  add_test(
    NAME libsvn_fs_x.string-table-test
    COMMAND string-table-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_fs_x
    WORKING_DIRECTORY $<TARGET_FILE_DIR:string-table-test>
  )
  set_tests_properties(libsvn_fs_x.string-table-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:string-table-test>)
  target_link_libraries(string-table-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs_x
    libsvn_subr
    external-apr
  )
  target_compile_definitions(string-table-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test fsfs string tables"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:string-table-test>"
  )
  if (WIN32)
    target_sources(string-table-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test svn_stringbuf_t utilities
if (SVN_ENABLE_TESTS)
  add_executable(string-test
    subversion/tests/libsvn_subr/string-test.c
  )
  add_test(
    NAME libsvn_subr.string-test
    COMMAND string-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:string-test>
  )
  set_tests_properties(libsvn_subr.string-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:string-test>)
  target_link_libraries(string-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(string-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test svn_stringbuf_t utilities"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:string-test>"
  )
  if (WIN32)
    target_sources(string-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test strings/reps in libsvn_fs_base
if (SVN_ENABLE_FS_BASE AND SVN_ENABLE_PROGRAMS)
  add_executable(strings-reps-test
    subversion/tests/libsvn_fs_base/strings-reps-test.c
  )
  if (WIN32)
    target_sources(strings-reps-test PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(strings-reps-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_fs
    libsvn_fs_base
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(strings-reps-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test strings/reps in libsvn_fs_base"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:strings-reps-test>"
  )
  if (WIN32)
    target_sources(strings-reps-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test the svn_subst_translate* functions
if (SVN_ENABLE_TESTS)
  add_executable(subst_translate-test
    subversion/tests/libsvn_subr/subst_translate-test.c
  )
  add_test(
    NAME libsvn_subr.subst_translate-test
    COMMAND subst_translate-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:subst_translate-test>
  )
  set_tests_properties(libsvn_subr.subst_translate-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:subst_translate-test>)
  target_link_libraries(subst_translate-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(subst_translate-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test the svn_subst_translate* functions"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:subst_translate-test>"
  )
  if (WIN32)
    target_sources(subst_translate-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Subversion Client
if (SVN_ENABLE_PROGRAMS)
  add_executable(svn
    subversion/svn/add-cmd.c
    subversion/svn/auth-cmd.c
    subversion/svn/blame-cmd.c
    subversion/svn/cat-cmd.c
    subversion/svn/changelist-cmd.c
    subversion/svn/checkout-cmd.c
    subversion/svn/cl-conflicts.c
    subversion/svn/cleanup-cmd.c
    subversion/svn/commit-cmd.c
    subversion/svn/conflict-callbacks.c
    subversion/svn/copy-cmd.c
    subversion/svn/delete-cmd.c
    subversion/svn/deprecated.c
    subversion/svn/diff-cmd.c
    subversion/svn/export-cmd.c
    subversion/svn/file-merge.c
    subversion/svn/filesize.c
    subversion/svn/help-cmd.c
    subversion/svn/import-cmd.c
    subversion/svn/info-cmd.c
    subversion/svn/list-cmd.c
    subversion/svn/lock-cmd.c
    subversion/svn/log-cmd.c
    subversion/svn/merge-cmd.c
    subversion/svn/mergeinfo-cmd.c
    subversion/svn/mkdir-cmd.c
    subversion/svn/move-cmd.c
    subversion/svn/notify.c
    subversion/svn/patch-cmd.c
    subversion/svn/propdel-cmd.c
    subversion/svn/propedit-cmd.c
    subversion/svn/propget-cmd.c
    subversion/svn/proplist-cmd.c
    subversion/svn/props.c
    subversion/svn/propset-cmd.c
    subversion/svn/relocate-cmd.c
    subversion/svn/resolve-cmd.c
    subversion/svn/resolved-cmd.c
    subversion/svn/revert-cmd.c
    subversion/svn/shelf-cmd.c
    subversion/svn/shelf2-cmd.c
    subversion/svn/similarity.c
    subversion/svn/status-cmd.c
    subversion/svn/status.c
    subversion/svn/svn.c
    subversion/svn/switch-cmd.c
    subversion/svn/unlock-cmd.c
    subversion/svn/update-cmd.c
    subversion/svn/upgrade-cmd.c
    subversion/svn/util.c
  )
  if (WIN32)
    target_sources(svn PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svn PRIVATE
    libsvn_client
    libsvn_wc
    libsvn_ra
    libsvn_delta
    libsvn_diff
    libsvn_subr
    external-apr
  )
  if (MSVC)
    set_target_properties(svn PROPERTIES LINK_FLAGS wsetargv.obj)
  endif()
  target_compile_definitions(svn PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Client"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svn>"
  )
  if (WIN32)
    target_sources(svn PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svn)
endif()

# svn-mergeinfo-normalizer
if (SVN_ENABLE_TOOLS)
  add_executable(svn-mergeinfo-normalizer
    tools/client-side/svn-mergeinfo-normalizer/analyze-cmd.c
    tools/client-side/svn-mergeinfo-normalizer/help-cmd.c
    tools/client-side/svn-mergeinfo-normalizer/log.c
    tools/client-side/svn-mergeinfo-normalizer/logic.c
    tools/client-side/svn-mergeinfo-normalizer/missing-branches.c
    tools/client-side/svn-mergeinfo-normalizer/normalize-cmd.c
    tools/client-side/svn-mergeinfo-normalizer/remove-branches-cmd.c
    tools/client-side/svn-mergeinfo-normalizer/svn-mergeinfo-normalizer.c
    tools/client-side/svn-mergeinfo-normalizer/wc_mergeinfo.c
  )
  if (WIN32)
    target_sources(svn-mergeinfo-normalizer PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svn-mergeinfo-normalizer PRIVATE
    libsvn_client
    libsvn_wc
    libsvn_ra
    libsvn_delta
    libsvn_diff
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svn-mergeinfo-normalizer PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svn-mergeinfo-normalizer>"
  )
  if (WIN32)
    target_sources(svn-mergeinfo-normalizer PRIVATE build/win32/svn.rc)
  endif()
endif()

# Tool to populate the node origins index of a repository
if (SVN_ENABLE_TOOLS)
  add_executable(svn-populate-node-origins-index
    tools/server-side/svn-populate-node-origins-index.c
  )
  if (WIN32)
    target_sources(svn-populate-node-origins-index PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svn-populate-node-origins-index PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svn-populate-node-origins-index PRIVATE
    "SVN_FILE_DESCRIPTION=Tool to populate the node origins index of a repository"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svn-populate-node-origins-index>"
  )
  if (WIN32)
    target_sources(svn-populate-node-origins-index PRIVATE build/win32/svn.rc)
  endif()
endif()

# svn-wc-db-tester
if (SVN_ENABLE_TESTS)
  add_executable(svn-wc-db-tester
    tools/dev/wc-ng/svn-wc-db-tester.c
  )
  if (WIN32)
    target_sources(svn-wc-db-tester PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svn-wc-db-tester PRIVATE
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svn-wc-db-tester PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svn-wc-db-tester>"
  )
  if (WIN32)
    target_sources(svn-wc-db-tester PRIVATE build/win32/svn.rc)
  endif()
endif()

# Subversion Repository Administrator
if (SVN_ENABLE_PROGRAMS)
  add_executable(svnadmin
    subversion/svnadmin/svnadmin.c
  )
  if (WIN32)
    target_sources(svnadmin PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnadmin PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  if (MSVC)
    set_target_properties(svnadmin PROPERTIES LINK_FLAGS wsetargv.obj)
  endif()
  target_compile_definitions(svnadmin PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Repository Administrator"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnadmin>"
  )
  if (WIN32)
    target_sources(svnadmin PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svnadmin)
endif()

# Authz config file tool
if (SVN_ENABLE_TOOLS)
  add_executable(svnauthz
    tools/server-side/svnauthz.c
  )
  if (WIN32)
    target_sources(svnauthz PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnauthz PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svnauthz PRIVATE
    "SVN_FILE_DESCRIPTION=Authz config file tool"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnauthz>"
  )
  if (WIN32)
    target_sources(svnauthz PRIVATE build/win32/svn.rc)
  endif()
endif()

# Authz config file validator
if (SVN_ENABLE_TOOLS)
  add_executable(svnauthz-validate
    tools/server-side/svnauthz.c
  )
  if (WIN32)
    target_sources(svnauthz-validate PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnauthz-validate PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svnauthz-validate PRIVATE
    "SVN_FILE_DESCRIPTION=Authz config file validator"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnauthz-validate>"
  )
  if (WIN32)
    target_sources(svnauthz-validate PRIVATE build/win32/svn.rc)
  endif()
endif()

# Benchmarking and diagnostics tool for the network layer
if (SVN_ENABLE_PROGRAMS)
  add_executable(svnbench
    subversion/svnbench/help-cmd.c
    subversion/svnbench/notify.c
    subversion/svnbench/null-blame-cmd.c
    subversion/svnbench/null-export-cmd.c
    subversion/svnbench/null-info-cmd.c
    subversion/svnbench/null-list-cmd.c
    subversion/svnbench/null-log-cmd.c
    subversion/svnbench/svnbench.c
    subversion/svnbench/util.c
  )
  if (WIN32)
    target_sources(svnbench PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnbench PRIVATE
    libsvn_client
    libsvn_wc
    libsvn_ra
    libsvn_subr
    libsvn_delta
    external-apr
  )
  target_compile_definitions(svnbench PRIVATE
    "SVN_FILE_DESCRIPTION=Benchmarking and diagnostics tool for the network layer"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnbench>"
  )
  if (WIN32)
    target_sources(svnbench PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svnbench)
endif()

# svnconflict
if (SVN_ENABLE_TOOLS)
  add_executable(svnconflict
    tools/client-side/svnconflict/svnconflict.c
  )
  if (WIN32)
    target_sources(svnconflict PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnconflict PRIVATE
    libsvn_client
    libsvn_wc
    libsvn_ra
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svnconflict PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnconflict>"
  )
  if (WIN32)
    target_sources(svnconflict PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test svndiff streams
if (SVN_ENABLE_TESTS)
  add_executable(svndiff-stream-test
    subversion/tests/libsvn_delta/svndiff-stream-test.c
  )
  add_test(
    NAME libsvn_delta.svndiff-stream-test
    COMMAND svndiff-stream-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_delta
    WORKING_DIRECTORY $<TARGET_FILE_DIR:svndiff-stream-test>
  )
  set_tests_properties(libsvn_delta.svndiff-stream-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:svndiff-stream-test>)
  target_link_libraries(svndiff-stream-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svndiff-stream-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test svndiff streams"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svndiff-stream-test>"
  )
  if (WIN32)
    target_sources(svndiff-stream-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# svndiff-test
if (SVN_ENABLE_TESTS)
  add_executable(svndiff-test
    subversion/tests/libsvn_delta/svndiff-test.c
  )
  if (WIN32)
    target_sources(svndiff-test PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svndiff-test PRIVATE
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svndiff-test PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svndiff-test>"
  )
  if (WIN32)
    target_sources(svndiff-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Subversion Dumpfile Filter
if (SVN_ENABLE_PROGRAMS)
  add_executable(svndumpfilter
    subversion/svndumpfilter/svndumpfilter.c
  )
  if (WIN32)
    target_sources(svndumpfilter PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svndumpfilter PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svndumpfilter PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Dumpfile Filter"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svndumpfilter>"
  )
  if (WIN32)
    target_sources(svndumpfilter PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svndumpfilter)
endif()

# Subversion FSFS Repository Manipulation Tool
if (SVN_ENABLE_PROGRAMS)
  add_executable(svnfsfs
    subversion/svnfsfs/dump-index-cmd.c
    subversion/svnfsfs/load-index-cmd.c
    subversion/svnfsfs/stats-cmd.c
    subversion/svnfsfs/svnfsfs.c
  )
  if (WIN32)
    target_sources(svnfsfs PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnfsfs PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_subr
    external-apr
  )
  if (WIN32)
    target_link_libraries(svnfsfs PRIVATE ws2_32.lib)
  endif()
  target_compile_definitions(svnfsfs PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion FSFS Repository Manipulation Tool"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnfsfs>"
  )
  if (WIN32)
    target_sources(svnfsfs PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svnfsfs)
endif()

# Subversion Repository Browser
if (SVN_ENABLE_PROGRAMS)
  add_executable(svnlook
    subversion/svnlook/svnlook.c
  )
  if (WIN32)
    target_sources(svnlook PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnlook PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_diff
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svnlook PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Repository Browser"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnlook>"
  )
  if (WIN32)
    target_sources(svnlook PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svnlook)
endif()

# Subversion Multiple URL Command Client
if (SVN_ENABLE_PROGRAMS)
  add_executable(svnmucc
    subversion/svnmucc/svnmucc.c
  )
  if (WIN32)
    target_sources(svnmucc PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnmucc PRIVATE
    libsvn_client
    libsvn_ra
    libsvn_subr
    libsvn_delta
    external-apr
  )
  target_compile_definitions(svnmucc PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Multiple URL Command Client"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnmucc>"
  )
  if (WIN32)
    target_sources(svnmucc PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svnmucc)
endif()

# Tool to Flag a Tree Conflict
if (SVN_ENABLE_TOOLS)
  add_executable(svnraisetreeconflict
    tools/dev/svnraisetreeconflict/svnraisetreeconflict.c
  )
  if (WIN32)
    target_sources(svnraisetreeconflict PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnraisetreeconflict PRIVATE
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svnraisetreeconflict PRIVATE
    "SVN_FILE_DESCRIPTION=Tool to Flag a Tree Conflict"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnraisetreeconflict>"
  )
  if (WIN32)
    target_sources(svnraisetreeconflict PRIVATE build/win32/svn.rc)
  endif()
endif()

# Subversion remote repository dumper and loader
if (SVN_ENABLE_PROGRAMS)
  add_executable(svnrdump
    subversion/svnrdump/dump_editor.c
    subversion/svnrdump/load_editor.c
    subversion/svnrdump/svnrdump.c
    subversion/svnrdump/util.c
  )
  if (WIN32)
    target_sources(svnrdump PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnrdump PRIVATE
    libsvn_client
    libsvn_ra
    libsvn_repos
    libsvn_delta
    libsvn_subr
    external-aprutil
    external-apr
  )
  target_compile_definitions(svnrdump PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion remote repository dumper and loader"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnrdump>"
  )
  if (WIN32)
    target_sources(svnrdump PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svnrdump)
endif()

# Subversion Server
if (SVN_ENABLE_RA_SVN AND SVN_ENABLE_PROGRAMS)
  add_executable(svnserve
    subversion/svnserve/cyrus_auth.c
    subversion/svnserve/log-escape.c
    subversion/svnserve/logger.c
    subversion/svnserve/serve.c
    subversion/svnserve/svnserve.c
    subversion/svnserve/winservice.c
  )
  if (WIN32)
    target_sources(svnserve PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnserve PRIVATE
    libsvn_repos
    libsvn_fs
    libsvn_delta
    libsvn_subr
    libsvn_ra_svn
    external-apr
    external-aprutil
  )
  if (WIN32)
    target_link_libraries(svnserve PRIVATE advapi32.lib ws2_32.lib)
  endif()
  target_compile_definitions(svnserve PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Server"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnserve>"
  )
  if (WIN32)
    target_sources(svnserve PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svnserve)
endif()

# Subversion repository replicator
if (SVN_ENABLE_PROGRAMS)
  add_executable(svnsync
    subversion/svnsync/svnsync.c
    subversion/svnsync/sync.c
  )
  if (WIN32)
    target_sources(svnsync PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnsync PRIVATE
    libsvn_ra
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svnsync PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion repository replicator"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnsync>"
  )
  if (WIN32)
    target_sources(svnsync PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svnsync)
endif()

# Subversion Revision Extractor
if (SVN_ENABLE_PROGRAMS)
  add_executable(svnversion
    subversion/svnversion/svnversion.c
  )
  if (WIN32)
    target_sources(svnversion PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(svnversion PRIVATE
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(svnversion PRIVATE
    "SVN_FILE_DESCRIPTION=Subversion Revision Extractor"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:svnversion>"
  )
  if (WIN32)
    target_sources(svnversion PRIVATE build/win32/svn.rc)
  endif()
  install(TARGETS svnversion)
endif()

# Test concurrent tasks
if (SVN_ENABLE_TESTS)
  add_executable(task-test
    subversion/tests/libsvn_subr/task-test.c
  )
  add_test(
    NAME libsvn_subr.task-test
    COMMAND task-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:task-test>
  )
  set_tests_properties(libsvn_subr.task-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:task-test>)
  target_link_libraries(task-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(task-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test concurrent tasks"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:task-test>"
  )
  if (WIN32)
    target_sources(task-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test time functions
if (SVN_ENABLE_TESTS)
  add_executable(time-test
    subversion/tests/libsvn_subr/time-test.c
  )
  add_test(
    NAME libsvn_subr.time-test
    COMMAND time-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:time-test>
  )
  set_tests_properties(libsvn_subr.time-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:time-test>)
  target_link_libraries(time-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(time-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test time functions"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:time-test>"
  )
  if (WIN32)
    target_sources(time-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test eol conversion and keyword substitution routines
if (SVN_ENABLE_TESTS)
  add_executable(translate-test
    subversion/tests/libsvn_subr/translate-test.c
  )
  add_test(
    NAME libsvn_subr.translate-test
    COMMAND translate-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:translate-test>
  )
  set_tests_properties(libsvn_subr.translate-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:translate-test>)
  target_link_libraries(translate-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(translate-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test eol conversion and keyword substitution routines"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:translate-test>"
  )
  if (WIN32)
    target_sources(translate-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test UTF-8 functions
if (SVN_ENABLE_TESTS)
  add_executable(utf-test
    subversion/tests/libsvn_subr/utf-test.c
  )
  add_test(
    NAME libsvn_subr.utf-test
    COMMAND utf-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:utf-test>
  )
  set_tests_properties(libsvn_subr.utf-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:utf-test>)
  target_link_libraries(utf-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(utf-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test UTF-8 functions"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:utf-test>"
  )
  if (WIN32)
    target_sources(utf-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# vdelta-test
if (SVN_ENABLE_TESTS)
  add_executable(vdelta-test
    subversion/tests/libsvn_delta/vdelta-test.c
  )
  if (WIN32)
    target_sources(vdelta-test PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(vdelta-test PRIVATE
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(vdelta-test PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:vdelta-test>"
  )
  if (WIN32)
    target_sources(vdelta-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# wc-incomplete-tester
if (SVN_ENABLE_TESTS)
  add_executable(wc-incomplete-tester
    subversion/tests/libsvn_wc/wc-incomplete-tester.c
  )
  if (WIN32)
    target_sources(wc-incomplete-tester PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(wc-incomplete-tester PRIVATE
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(wc-incomplete-tester PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:wc-incomplete-tester>"
  )
  if (WIN32)
    target_sources(wc-incomplete-tester PRIVATE build/win32/svn.rc)
  endif()
endif()

# wc-lock-tester
if (SVN_ENABLE_TESTS)
  add_executable(wc-lock-tester
    subversion/tests/libsvn_wc/wc-lock-tester.c
  )
  if (WIN32)
    target_sources(wc-lock-tester PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(wc-lock-tester PRIVATE
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(wc-lock-tester PRIVATE
    "SVN_FILE_DESCRIPTION="
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:wc-lock-tester>"
  )
  if (WIN32)
    target_sources(wc-lock-tester PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test Sqlite query evaluation
if (SVN_ENABLE_TESTS)
  add_executable(wc-queries-test
    subversion/tests/libsvn_wc/../../libsvn_subr/sqlite3wrapper.c
    subversion/tests/libsvn_wc/wc-queries-test.c
  )
  add_test(
    NAME libsvn_wc.wc-queries-test
    COMMAND wc-queries-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_wc
    WORKING_DIRECTORY $<TARGET_FILE_DIR:wc-queries-test>
  )
  set_tests_properties(libsvn_wc.wc-queries-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:wc-queries-test>)
  target_link_libraries(wc-queries-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
    external-sqlite
  )
  target_compile_definitions(wc-queries-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test Sqlite query evaluation"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:wc-queries-test>"
  )
  if (WIN32)
    target_sources(wc-queries-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test the main WC API functions
if (SVN_ENABLE_TESTS)
  add_executable(wc-test
    subversion/tests/libsvn_wc/utils.c
    subversion/tests/libsvn_wc/wc-test.c
  )
  add_test(
    NAME libsvn_wc.wc-test
    COMMAND wc-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_wc
    WORKING_DIRECTORY $<TARGET_FILE_DIR:wc-test>
  )
  set_tests_properties(libsvn_wc.wc-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:wc-test>)
  target_link_libraries(wc-test PRIVATE
    libsvn_client
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(wc-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test the main WC API functions"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:wc-test>"
  )
  if (WIN32)
    target_sources(wc-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test delta window generation
if (SVN_ENABLE_TESTS)
  add_executable(window-test
    subversion/tests/libsvn_delta/window-test.c
  )
  add_test(
    NAME libsvn_delta.window-test
    COMMAND window-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_delta
    WORKING_DIRECTORY $<TARGET_FILE_DIR:window-test>
  )
  set_tests_properties(libsvn_delta.window-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:window-test>)
  target_link_libraries(window-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_delta
    libsvn_subr
    external-apr
  )
  target_compile_definitions(window-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test delta window generation"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:window-test>"
  )
  if (WIN32)
    target_sources(window-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Tool to verify x509 certificates
if (SVN_ENABLE_TOOLS)
  add_executable(x509-parser
    tools/dev/x509-parser.c
  )
  if (WIN32)
    target_sources(x509-parser PRIVATE build/win32/compatibility.manifest)
  endif()
  target_link_libraries(x509-parser PRIVATE
    libsvn_subr
    external-apr
  )
  target_compile_definitions(x509-parser PRIVATE
    "SVN_FILE_DESCRIPTION=Tool to verify x509 certificates"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:x509-parser>"
  )
  if (WIN32)
    target_sources(x509-parser PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test x509 parser
if (SVN_ENABLE_TESTS)
  add_executable(x509-test
    subversion/tests/libsvn_subr/x509-test.c
  )
  add_test(
    NAME libsvn_subr.x509-test
    COMMAND x509-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:x509-test>
  )
  set_tests_properties(libsvn_subr.x509-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:x509-test>)
  target_link_libraries(x509-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(x509-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test x509 parser"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:x509-test>"
  )
  if (WIN32)
    target_sources(x509-test PRIVATE build/win32/svn.rc)
  endif()
endif()

# Test XML parser in libsvn_subr
if (SVN_ENABLE_TESTS)
  add_executable(xml-test
    subversion/tests/libsvn_subr/xml-test.c
  )
  add_test(
    NAME libsvn_subr.xml-test
    COMMAND xml-test --srcdir ${CMAKE_SOURCE_DIR}/subversion/tests/libsvn_subr
    WORKING_DIRECTORY $<TARGET_FILE_DIR:xml-test>
  )
  set_tests_properties(libsvn_subr.xml-test PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=$<TARGET_FILE_DIR:xml-test>)
  target_link_libraries(xml-test PRIVATE
    libsvn_test
    libsvn_wc
    libsvn_subr
    external-apr
  )
  target_compile_definitions(xml-test PRIVATE
    "SVN_FILE_DESCRIPTION=Test XML parser in libsvn_subr"
    "SVN_FILE_NAME=$<TARGET_FILE_NAME:xml-test>"
  )
  if (WIN32)
    target_sources(xml-test PRIVATE build/win32/svn.rc)
  endif()
endif()

