blob: 2436d1277426fa3369bc9de88d56436319c7d05d [file] [log] [blame]
Marc Kupietz6afb3522021-03-22 17:22:55 +01001cmake_minimum_required(VERSION 3.9)
Marc Kupietzd724abd2024-10-21 18:41:25 +02002project(dereko2vec VERSION 0.9.1 DESCRIPTION "Fork from wang2vec with extensions for re-training and count based models")
Marc Kupietz6afb3522021-03-22 17:22:55 +01003set(CMAKE_VERBOSE_MAKEFILE on)
Marc Kupietz61485ad2023-12-22 16:16:59 +01004if (CMAKE_BUILD_TYPE MATCHES Debug)
5 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lm -g -O0 -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-but-set-parameter -Wno-unused-value -Wno-unused-result")
6else ()
7 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lm -pthread -O3 -march=native -mtune=native -Wall -funroll-loops")
8endif ()
Marc Kupietz5846b332025-02-10 17:16:31 +01009
10# First, try to find static versions
11find_library(ZLIB_STATIC NAMES libz.a)
12find_library(BZ2_STATIC NAMES libbz2.a)
13find_library(LZ4_STATIC NAMES liblz4.a)
14find_library(ZSTD_STATIC NAMES libzstd.a)
15
16# Set each library, preferring static if found
17set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} pthread rt snappy)
18if(ZLIB_STATIC)
19 set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${ZLIB_STATIC})
20else()
21 set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} z)
22endif()
23
24if(BZ2_STATIC)
25 set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${BZ2_STATIC})
26else()
27 set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} bz2)
28endif()
29
30if(LZ4_STATIC)
31 set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${LZ4_STATIC})
32else()
33 set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} lz4)
34endif()
35
36if(ZSTD_STATIC)
37 set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${ZSTD_STATIC})
38else()
39 set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} zstd)
40endif()
41
42set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} stdc++ dl)
43
Marc Kupietz6afb3522021-03-22 17:22:55 +010044include(GNUInstallDirs)
45
46include_directories(/usr/local/include;/usr/local/kl/include)
47link_directories(/usr/local/kl/lib;/usr/local/lib;/usr/local/lib64)
48
49find_library(COLLOCATORDB libcollocatordb_static.a REQUIRED)
50if (NOT COLLOCATORDB)
51 message(FATAL_ERROR "No libcollocatordb_static.a found. Please install from https://korap.ids-mannheim.de/gerrit/plugins/gitiles/private/collocatordb")
52endif ()
53
54find_library(ROCKSDB librocksdb.a REQUIRED)
55if (NOT ROCKSDB)
56 message(FATAL_ERROR "No librocksdb.a found. Please install like suggested here https://korap.ids-mannheim.de/gerrit/plugins/gitiles/private/collocatordb#install-rocksdb-and-prerequisites")
57endif ()
58
59file(GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c)
60foreach (mysourcefile ${APP_SOURCES})
61 # I used a simple string replace, to cut off .cpp.
62 string(REPLACE ".c" "" myname ${mysourcefile})
63 string(REGEX REPLACE ".*/" "" myname ${myname})
64 add_executable(${myname} ${mysourcefile})
65 # Make sure YourLib is linked to each app
66 if (${myname} MATCHES "derek")
67 target_link_libraries(${myname} ${COLLOCATORDB} ${ROCKSDB} ${ADDITIONAL_LIBS})
68 endif ()
69endforeach (mysourcefile ${APP_SOURCES})
Marc Kupietz31e2e312021-03-22 17:22:57 +010070
71enable_testing()
72find_program(BASH_PROGRAM bash)
73if (BASH_PROGRAM)
74 add_test(type-3-test ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test-type-3.sh)
75else ()
76 message(SEND_ERROR "Cannot find bash, needed for testing")
77endif ()