Marc Kupietz | ed0bfcf | 2021-03-14 14:56:15 +0100 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.9) |
| 2 | project(collocatordb VERSION 1.2.0 DESCRIPTION "Storing and retrieving collocation counts based on RocksDB") |
Marc Kupietz | 673bd81 | 2021-03-14 17:27:44 +0100 | [diff] [blame] | 3 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fno-rtti -std=c++11 -std=gnu++11") |
Marc Kupietz | ed0bfcf | 2021-03-14 14:56:15 +0100 | [diff] [blame] | 4 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") |
| 5 | |
| 6 | include(GNUInstallDirs) |
Marc Kupietz | 673bd81 | 2021-03-14 17:27:44 +0100 | [diff] [blame] | 7 | include_directories(/usr/local/include;/usr/local/kl/include) |
| 8 | link_directories(/usr/local/lib;/usr/local/kl/lib) |
| 9 | find_library(ROCKSDB NAMES librocksdb.so.5.11 librocksdb.so.5.10 librocksdb.so.5) |
Marc Kupietz | 1b09e4d | 2021-03-14 15:20:19 +0100 | [diff] [blame] | 10 | find_library(ROCKSDB_STATIC librocksdb.a) |
| 11 | |
Marc Kupietz | ed0bfcf | 2021-03-14 14:56:15 +0100 | [diff] [blame] | 12 | enable_testing() |
| 13 | add_library(collocatordb SHARED src/collocatordb.cc) |
Marc Kupietz | 673bd81 | 2021-03-14 17:27:44 +0100 | [diff] [blame] | 14 | target_link_libraries(collocatordb pthread rt snappy z bz2 lz4 zstd ${ROCKSDB} dl) |
Marc Kupietz | ed0bfcf | 2021-03-14 14:56:15 +0100 | [diff] [blame] | 15 | set_target_properties(collocatordb PROPERTIES |
| 16 | VERSION ${PROJECT_VERSION} |
| 17 | SOVERSION 1 |
| 18 | PUBLIC_HEADER src/collocatordb.h) |
| 19 | |
| 20 | add_library(collocatordb_static STATIC src/collocatordb.cc) |
Marc Kupietz | 673bd81 | 2021-03-14 17:27:44 +0100 | [diff] [blame] | 21 | target_link_libraries(collocatordb_static ${ROCKSDB_STATIC} pthread rt snappy z bz2 lz4 zstd dl) |
Marc Kupietz | ed0bfcf | 2021-03-14 14:56:15 +0100 | [diff] [blame] | 22 | |
| 23 | add_executable(basic_test tests/basic_test.c tests/acutest.h) |
| 24 | TARGET_LINK_LIBRARIES(basic_test ${ROCKSDB} collocatordb) |
| 25 | add_test(BASIC_TEST basic_test) |
| 26 | |
Marc Kupietz | 1b09e4d | 2021-03-14 15:20:19 +0100 | [diff] [blame] | 27 | add_executable(static_library_test tests/basic_test.c tests/acutest.h) |
| 28 | TARGET_LINK_LIBRARIES(static_library_test collocatordb_static) |
| 29 | add_test(STATIC_LIBRARY_TEST static_library_test) |
| 30 | |
Marc Kupietz | ed0bfcf | 2021-03-14 14:56:15 +0100 | [diff] [blame] | 31 | configure_file(collocatordb.pc.in collocatordb.pc @ONLY) |
| 32 | target_include_directories(collocatordb PRIVATE .) |
| 33 | install(TARGETS collocatordb collocatordb_static |
| 34 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 35 | PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 36 | install(FILES ${CMAKE_BINARY_DIR}/collocatordb.pc |
| 37 | DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) |
| 38 | |
| 39 | # Install library |
| 40 | install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME}) |