cmake_minimum_required(VERSION 2.6)
enable_testing()
include(CheckIncludeFile) 
project(carvpath C)
set(prefix      ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir      ${CMAKE_INSTALL_PREFIX}/lib)
set(includedir  ${CMAKE_INSTALL_PREFIX}/include)
ADD_DEFINITIONS(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LIBCARVPATH_DEBUG_ALLOC)
FIND_PACKAGE(OpenSSL REQUIRED)
CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE3_H)
IF(HAVE_SQLITE3_H)
ELSE(HAVE_SQLITE3_H)
  MESSAGE(FATAL_ERROR "sqlite3.h headers not found.")
ENDIF(HAVE_SQLITE3_H)
add_library(carvpath SHARED libcarvpath.c longtoken.c entity.c fragment.c utility.c)
SET_TARGET_PROPERTIES(carvpath PROPERTIES VERSION 2.3.0 SOVERSION 2)
target_link_libraries(carvpath crypto sqlite3)
install_targets(/lib carvpath)
install(FILES libcarvpath.h DESTINATION include)
add_executable(apitest apitest.c)
target_link_libraries(apitest carvpath)
add_test(tests.api apitest)
add_executable(chunktest chunktest.c)
target_link_libraries(chunktest carvpath)
add_test(tests.chunk chunktest)
add_executable(trailtest trailtest.c)
target_link_libraries(trailtest carvpath)
add_test(tests.trail trailtest)
add_executable(nulnultest nulnultest.c)
target_link_libraries(nulnultest carvpath)
add_test(tests.nulnul nulnultest)
add_executable(fragtest fragtest.c)
target_link_libraries(fragtest carvpath)
add_test(tests.fragments fragtest)
add_executable(flattentest flattentest.c)
target_link_libraries(flattentest carvpath)
add_test(tests.flatten flattentest)
add_executable(shortsubtest shortsubtest.c)
target_link_libraries(shortsubtest carvpath)
add_test(tests.shortsub shortsubtest)
add_executable(leaktest leaktest.c)
target_link_libraries(leaktest carvpath)
add_test(tests.leak leaktest)
