set(SOURCES
    apr.cpp
    client_annotate.cpp
    client_cat.cpp
    client.cpp
    client_diff.cpp
    client_ls.cpp
    client_modify.cpp
    client_property.cpp
    client_status.cpp
    context.cpp
    datetime.cpp
    dirent.cpp
    entry.cpp
    exception.cpp
    log_entry.cpp
    path.cpp
    pool.cpp
    revision.cpp
    status.cpp
    targets.cpp
    url.cpp
    version_check.cpp
    wc.cpp
    lock_entry.cpp
    client_lock.cpp
    info_entry.cpp
    client_impl.cpp
    contextdata.cpp
    commititem.cpp
    repository.cpp
    repositorydata.cpp
    repositorylistener.cpp
    svnstream.cpp
    diff_data.cpp
    svnfilestream.cpp
    stringarray.cpp
    diffoptions.cpp
    conflictdescription.cpp
    conflictresult.cpp
    client_merge.cpp
    cache/LogCache.cpp
    cache/ReposLog.cpp
    cache/DatabaseException.h
    cache/DatabaseException.cpp
    )

set(CACHEINST_HEADERS
    cache/LogCache.h
    cache/ReposLog.h
    cache/DatabaseException.h
)

set(INST_HEADERS
    annotate_line.h
    apr.h
    check.h
    client.h
    commititem.h
    context.h
    context_listener.h
    datetime.h
    dirent.h
    entry.h
    exception.h
    info_entry.h
    lock_entry.h
    log_entry.h
    path.h
    pool.h
    repository.h
    repositorylistener.h
    revision.h
    smart_pointer.h
    shared_pointer.h
    status.h
    svnfilestream.h
    svnstream.h
    svnqttypes.h
    targets.h
    url.h
    version_check.h
    wc.h
    stringarray.h
    diffoptions.h
    conflictdescription.h
    conflictresult.h
    )

file(GLOB svnhdr RELATIVE  ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
set(svnhdr ${svnhdr} ${CACHE_INST_HEADERS})


        set(TOUTF8 "utf8")
        set(FROMUTF8 "fromUtf8")
        set(QLIST "TQValueList")
        set(TOASCII "latin1")
        set(HOMEDIR "homeDirPath")
        set(QDATABASE "TQSqlDatabase*")
        set(QLONG "TQ_LLONG")
    set(svnqt-name svnqt)

if (HAVE_GCC_VISIBILITY)
    set(_SVNQT_EXPORT "__attribute__ ((visibility(\"default\")))")
    set(_SVNQT_NOEXPORT "__attribute__ ((visibility(\"hidden\")))")
endif (HAVE_GCC_VISIBILITY)

configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/svnqt_defines.h.in"
    "${CMAKE_CURRENT_BINARY_DIR}/svnqt_defines.h"
    IMMEDIATE
    @ONLY)

set(INST_HEADERS ${INST_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/svnqt_defines.h)
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})

add_library(${svnqt-name} SHARED ${SOURCES} ${svnhdr})
    set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX})
    set_target_properties(${svnqt-name}
        PROPERTIES
        COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})

set(LIB_MAJOR 4)
set(LIB_MINOR 2)
set(LIB_RELEASE 2)

set(_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})

set_target_properties(${svnqt-name} PROPERTIES
    SOVERSION ${LIB_MAJOR}
    VERSION ${_soversion})

set(ALL_LINKFLAGS ${APR_EXTRA_LIBFLAGS})
set(ALL_LINKFLAGS "${ALL_LINKFLAGS} ${APU_EXTRA_LIBFLAGS}")
set_target_properties(${svnqt-name} PROPERTIES LINK_FLAGS "${ALL_LINKFLAGS} ${LINK_NO_UNDEFINED}")
target_link_libraries(${svnqt-name} ${TQT_LIBRARIES} ${SUBVERSION_ALL_LIBS} ${ALL_LINKFLAGS})

# if (SQLITE_FOUND)
    target_link_libraries(${svnqt-name} ${SQLITE_LIBRARIES})
    include_directories(${SQLITE_INCLUDE_DIR})
# else (SQLITE_FOUND)
#     target_link_libraries(${svnqt-name} ${QT_QTSQL_LIBRARY})
# endif (SQLITE_FOUND)

# Just a small linking test
if (BUILD_TESTS)
    add_executable(testlink testmain.cpp)
    target_link_libraries(testlink ${svnqt-name})
endif (BUILD_TESTS)

    install(TARGETS ${svnqt-name} DESTINATION ${LIB_INSTALL_DIR})
    install(FILES ${INST_HEADERS} DESTINATION include/${svnqt-name})
    install(FILES ${CACHEINST_HEADERS} DESTINATION include/${svnqt-name}/cache)

if (BUILD_TESTS)
  add_subdirectory(tests)
  add_subdirectory(cache/test)
endif (BUILD_TESTS)
