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)
