summaryrefslogtreecommitdiff
path: root/ept/CMakeLists.txt
blob: 5f27f14ee5a4c69d6a0e3702522d2aa77c621f99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
project( ept )
include( ${WIBBLE_TEST_CMAKE} )

file( GLOB src *.cpp debtags/*.cc debtags/maint/*.cc debtags/coll/*.cc
  apt/*.cc axi/*.cc utils/*.cc )

file( GLOB h_top *.h )
file( GLOB h_apt apt/*.h )
file( GLOB h_debtags debtags/*.h debtags/*.tcc )
file( GLOB h_debtags_maint debtags/maint/*.h debtags/maint/*.tcc )
file( GLOB h_axi axi/*.h )
file( GLOB h_utils utils/*.h )

file( GLOB debtagstesth debtags/*.test.h debtags/maint/*.test.h )
file( GLOB apttesth apt/*.test.h )
file( GLOB axitesth axi/*.test.h )
set( testh ${debtagstesth} ${apttesth} ${axitesth} )

include_directories( ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} 
                     ${TAGCOLL_INCLUDE_DIRS} ${WIBBLE_INCLUDE_DIRS} )
link_libraries( ${WIBBLE_LIBRARIES} ${TAGCOLL_LIBRARIES} apt-pkg xapian -lpthread )
add_definitions( --std=c++11 -fexceptions -fPIC -fvisibility=default )

add_library( ept SHARED ${src} )
add_library( ept-static STATIC ${src} )
set_target_properties( ept PROPERTIES SOVERSION ${LIBEPT_SOVERSION} CLEAN_DIRECT_OUTPUT 1)
set_target_properties( ept-static PROPERTIES SOVERSION ${LIBEPT_SOVERSION} OUTPUT_NAME "ept" CLEAN_DIRECT_OUTPUT 1)

set( TEST_ENV_DIR ${ept_BINARY_DIR}/test-env/ )

configure_file( ${ept_SOURCE_DIR}/config.h.cmake-in
  ${ept_BINARY_DIR}/config.h )

set( prefix "${CMAKE_INSTALL_PREFIX}" )
set( exec_prefix "${prefix}/bin" )
set( libdir "${prefix}/lib" )
set( includedir "${prefix}/include" )
configure_file( ${ept_SOURCE_DIR}/libept.pc.in
  ${ept_BINARY_DIR}/libept.pc @ONLY )

# regression testing
link_directories( ${CMAKE_CURRENT_BINARY_DIR}/../lib )
link_libraries( ept )
wibble_add_test( ept-test ${testh} )

set( datastamp ${CMAKE_CURRENT_BINARY_DIR}/data-stamp )
set( datadir ${CMAKE_CURRENT_SOURCE_DIR}/test-data )
set( listfile wherever_debian_._Packages )

wibble_check_target( ept-test ${datastamp} )

execute_process( COMMAND dpkg --print-architecture OUTPUT_VARIABLE ARCH )
string( REPLACE "\n" "" ARCH "${ARCH}" )

add_custom_command(
  OUTPUT ${datastamp}
  COMMAND mkdir -p test-env/etc test-env/state/lists/partial
		           test-env/cache test-env/debtags
			   test-env/cache/archives/partial test-env/desktop
  COMMAND sed -e s,i386,${ARCH}, < ${datadir}/packagelist > test-env/state/lists/${listfile}
  COMMAND cp -a ${datadir}/etc/sources.list test-env/etc/
  COMMAND sed -e s,i386,${ARCH}, < ${datadir}/dpkg-status > test-env/dpkg-status
  COMMAND cp -a ${datadir}/desktop/*.desktop test-env/desktop/
  COMMAND cp ${datadir}/debtags/package-tags test-env/debtags/package-tags
  COMMAND cp ${datadir}/debtags/vocabulary test-env/debtags/vocabulary
  COMMAND mkdir -p test-env/debtags/empty
  COMMAND mkdir -p test-env/debtags/user
  COMMAND mkdir -p test-env/xapian/
  COMMAND touch data-stamp )

install( TARGETS ept ept-static
    LIBRARY DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}
    ARCHIVE DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE} )

install( FILES ${ept_BINARY_DIR}/libept.pc DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig )
install( FILES ${h_top} DESTINATION include/ept )
install( FILES ${h_apt} DESTINATION include/ept/apt )
install( FILES ${h_debtags} DESTINATION include/ept/debtags )
install( FILES ${h_debtags_maint} DESTINATION include/ept/debtags/maint )
install( FILES ${h_axi} DESTINATION include/ept/axi )
install( FILES ${h_utils} DESTINATION include/ept/utils )