blob: 684754c1309a24f9fc8054a1e7f7e2d87a7cc6f7 [file] [log] [blame]
Marc Kupietzed0bfcf2021-03-14 14:56:15 +01001cmake_minimum_required(VERSION 3.9)
2project(collocatordb VERSION 1.2.0 DESCRIPTION "Storing and retrieving collocation counts based on RocksDB")
3set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fno-rtti")
4set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
5
6include(GNUInstallDirs)
7include_directories(/usr/local/include)
8find_library(ROCKSDB librocksdb.so.5.11)
Marc Kupietz1b09e4d2021-03-14 15:20:19 +01009find_library(ROCKSDB_STATIC librocksdb.a)
10
Marc Kupietzed0bfcf2021-03-14 14:56:15 +010011enable_testing()
12add_library(collocatordb SHARED src/collocatordb.cc)
13target_link_libraries(collocatordb pthread rt snappy z bz2 lz4 zstd ${ROCKSDB})
14set_target_properties(collocatordb PROPERTIES
15 VERSION ${PROJECT_VERSION}
16 SOVERSION 1
17 PUBLIC_HEADER src/collocatordb.h)
18
19add_library(collocatordb_static STATIC src/collocatordb.cc)
Marc Kupietz1b09e4d2021-03-14 15:20:19 +010020target_link_libraries(collocatordb_static ${ROCKSDB_STATIC} pthread rt snappy z bz2 lz4 zstd)
Marc Kupietzed0bfcf2021-03-14 14:56:15 +010021
22add_executable(basic_test tests/basic_test.c tests/acutest.h)
23TARGET_LINK_LIBRARIES(basic_test ${ROCKSDB} collocatordb)
24add_test(BASIC_TEST basic_test)
25
Marc Kupietz1b09e4d2021-03-14 15:20:19 +010026add_executable(static_library_test tests/basic_test.c tests/acutest.h)
27TARGET_LINK_LIBRARIES(static_library_test collocatordb_static)
28add_test(STATIC_LIBRARY_TEST static_library_test)
29
Marc Kupietzed0bfcf2021-03-14 14:56:15 +010030configure_file(collocatordb.pc.in collocatordb.pc @ONLY)
31target_include_directories(collocatordb PRIVATE .)
32install(TARGETS collocatordb collocatordb_static
33 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
34 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
35install(FILES ${CMAKE_BINARY_DIR}/collocatordb.pc
36 DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
37
38# Install library
39install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})