Marc Kupietz | ed0bfcf | 2021-03-14 14:56:15 +0100 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.9) |
Marc Kupietz | 3919b63 | 2021-03-15 15:03:48 +0100 | [diff] [blame] | 2 | project(collocatordb VERSION 1.3.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 | 15f56e7 | 2021-03-15 14:58:13 +0100 | [diff] [blame] | 7 | |
| 8 | # the RPATH to be used when installing, but only if it's not a system directory |
| 9 | list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) |
| 10 | if("${isSystemDir}" STREQUAL "-1") |
| 11 | set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") |
| 12 | endif("${isSystemDir}" STREQUAL "-1") |
| 13 | |
Marc Kupietz | 673bd81 | 2021-03-14 17:27:44 +0100 | [diff] [blame] | 14 | include_directories(/usr/local/include;/usr/local/kl/include) |
Marc Kupietz | 15f56e7 | 2021-03-15 14:58:13 +0100 | [diff] [blame] | 15 | link_directories(/usr/local/kl/lib /usr/local/lib) |
| 16 | find_library(ROCKSDB NAMES librocksdb.so.5.11) |
Marc Kupietz | 1b09e4d | 2021-03-14 15:20:19 +0100 | [diff] [blame] | 17 | find_library(ROCKSDB_STATIC librocksdb.a) |
| 18 | |
Marc Kupietz | ed0bfcf | 2021-03-14 14:56:15 +0100 | [diff] [blame] | 19 | enable_testing() |
| 20 | add_library(collocatordb SHARED src/collocatordb.cc) |
Marc Kupietz | 673bd81 | 2021-03-14 17:27:44 +0100 | [diff] [blame] | 21 | 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] | 22 | set_target_properties(collocatordb PROPERTIES |
| 23 | VERSION ${PROJECT_VERSION} |
| 24 | SOVERSION 1 |
| 25 | PUBLIC_HEADER src/collocatordb.h) |
| 26 | |
| 27 | add_library(collocatordb_static STATIC src/collocatordb.cc) |
Marc Kupietz | 673bd81 | 2021-03-14 17:27:44 +0100 | [diff] [blame] | 28 | 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] | 29 | |
| 30 | add_executable(basic_test tests/basic_test.c tests/acutest.h) |
| 31 | TARGET_LINK_LIBRARIES(basic_test ${ROCKSDB} collocatordb) |
| 32 | add_test(BASIC_TEST basic_test) |
| 33 | |
Marc Kupietz | 1b09e4d | 2021-03-14 15:20:19 +0100 | [diff] [blame] | 34 | add_executable(static_library_test tests/basic_test.c tests/acutest.h) |
| 35 | TARGET_LINK_LIBRARIES(static_library_test collocatordb_static) |
| 36 | add_test(STATIC_LIBRARY_TEST static_library_test) |
| 37 | |
Marc Kupietz | ed0bfcf | 2021-03-14 14:56:15 +0100 | [diff] [blame] | 38 | # Install library |
Marc Kupietz | 8f977ca | 2021-03-22 17:52:52 +0100 | [diff] [blame] | 39 | install(TARGETS ${PROJECT_NAME} collocatordb_static |
Marc Kupietz | 15f56e7 | 2021-03-15 14:58:13 +0100 | [diff] [blame] | 40 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
Marc Kupietz | d15845c | 2022-04-11 22:28:11 +0200 | [diff] [blame^] | 41 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
Marc Kupietz | 15f56e7 | 2021-03-15 14:58:13 +0100 | [diff] [blame] | 42 | PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |