blob: 2c2aa20eee4910de40eedaa9d748eca2372471f8 [file] [log] [blame]
Marc Kupietz6afb3522021-03-22 17:22:55 +01001cmake_minimum_required(VERSION 3.9)
2project(dereko2vec VERSION 0.9.0 DESCRIPTION "Fork from wang2vec with extensions for re-training and count based models")
3set(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 ()
9set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} pthread rt snappy z bz2 lz4 zstd stdc++ dl)
Marc Kupietz6afb3522021-03-22 17:22:55 +010010include(GNUInstallDirs)
11
12include_directories(/usr/local/include;/usr/local/kl/include)
13link_directories(/usr/local/kl/lib;/usr/local/lib;/usr/local/lib64)
14
15find_library(COLLOCATORDB libcollocatordb_static.a REQUIRED)
16if (NOT COLLOCATORDB)
17 message(FATAL_ERROR "No libcollocatordb_static.a found. Please install from https://korap.ids-mannheim.de/gerrit/plugins/gitiles/private/collocatordb")
18endif ()
19
20find_library(ROCKSDB librocksdb.a REQUIRED)
21if (NOT ROCKSDB)
22 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")
23endif ()
24
25file(GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c)
26foreach (mysourcefile ${APP_SOURCES})
27 # I used a simple string replace, to cut off .cpp.
28 string(REPLACE ".c" "" myname ${mysourcefile})
29 string(REGEX REPLACE ".*/" "" myname ${myname})
30 add_executable(${myname} ${mysourcefile})
31 # Make sure YourLib is linked to each app
32 if (${myname} MATCHES "derek")
33 target_link_libraries(${myname} ${COLLOCATORDB} ${ROCKSDB} ${ADDITIONAL_LIBS})
34 endif ()
35endforeach (mysourcefile ${APP_SOURCES})
Marc Kupietz31e2e312021-03-22 17:22:57 +010036
37enable_testing()
38find_program(BASH_PROGRAM bash)
39if (BASH_PROGRAM)
40 add_test(type-3-test ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test-type-3.sh)
Marc Kupietz879333c2023-12-20 11:41:09 +010041 add_test(type-3-test-with-metadata ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test-type-3-with-metadata.sh)
Marc Kupietz31e2e312021-03-22 17:22:57 +010042else ()
43 message(SEND_ERROR "Cannot find bash, needed for testing")
44endif ()