blob: 9479d905c4d76698d57d0b4b59b50198b2b4c869 [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")
Marc Kupietz673bd812021-03-14 17:27:44 +01003set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fno-rtti -std=c++11 -std=gnu++11")
Marc Kupietzed0bfcf2021-03-14 14:56:15 +01004set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
5
6include(GNUInstallDirs)
Marc Kupietz15f56e72021-03-15 14:58:13 +01007
8# the RPATH to be used when installing, but only if it's not a system directory
9list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
10if("${isSystemDir}" STREQUAL "-1")
11 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
12endif("${isSystemDir}" STREQUAL "-1")
13
Marc Kupietz673bd812021-03-14 17:27:44 +010014include_directories(/usr/local/include;/usr/local/kl/include)
Marc Kupietz15f56e72021-03-15 14:58:13 +010015link_directories(/usr/local/kl/lib /usr/local/lib)
16find_library(ROCKSDB NAMES librocksdb.so.5.11)
Marc Kupietz1b09e4d2021-03-14 15:20:19 +010017find_library(ROCKSDB_STATIC librocksdb.a)
18
Marc Kupietzed0bfcf2021-03-14 14:56:15 +010019enable_testing()
20add_library(collocatordb SHARED src/collocatordb.cc)
Marc Kupietz673bd812021-03-14 17:27:44 +010021target_link_libraries(collocatordb pthread rt snappy z bz2 lz4 zstd ${ROCKSDB} dl)
Marc Kupietzed0bfcf2021-03-14 14:56:15 +010022set_target_properties(collocatordb PROPERTIES
23 VERSION ${PROJECT_VERSION}
24 SOVERSION 1
25 PUBLIC_HEADER src/collocatordb.h)
26
27add_library(collocatordb_static STATIC src/collocatordb.cc)
Marc Kupietz673bd812021-03-14 17:27:44 +010028target_link_libraries(collocatordb_static ${ROCKSDB_STATIC} pthread rt snappy z bz2 lz4 zstd dl)
Marc Kupietzed0bfcf2021-03-14 14:56:15 +010029
30add_executable(basic_test tests/basic_test.c tests/acutest.h)
31TARGET_LINK_LIBRARIES(basic_test ${ROCKSDB} collocatordb)
32add_test(BASIC_TEST basic_test)
33
Marc Kupietz1b09e4d2021-03-14 15:20:19 +010034add_executable(static_library_test tests/basic_test.c tests/acutest.h)
35TARGET_LINK_LIBRARIES(static_library_test collocatordb_static)
36add_test(STATIC_LIBRARY_TEST static_library_test)
37
Marc Kupietzed0bfcf2021-03-14 14:56:15 +010038# Install library
Marc Kupietz15f56e72021-03-15 14:58:13 +010039install(TARGETS ${PROJECT_NAME}
40 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
41 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})