Marc Kupietz | 6afb352 | 2021-03-22 17:22:55 +0100 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.9) |
Marc Kupietz | d724abd | 2024-10-21 18:41:25 +0200 | [diff] [blame] | 2 | project(dereko2vec VERSION 0.9.1 DESCRIPTION "Fork from wang2vec with extensions for re-training and count based models") |
Marc Kupietz | 6afb352 | 2021-03-22 17:22:55 +0100 | [diff] [blame] | 3 | set(CMAKE_VERBOSE_MAKEFILE on) |
Marc Kupietz | 61485ad | 2023-12-22 16:16:59 +0100 | [diff] [blame] | 4 | if (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") |
| 6 | else () |
| 7 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lm -pthread -O3 -march=native -mtune=native -Wall -funroll-loops") |
| 8 | endif () |
| 9 | set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} pthread rt snappy z bz2 lz4 zstd stdc++ dl) |
Marc Kupietz | 6afb352 | 2021-03-22 17:22:55 +0100 | [diff] [blame] | 10 | include(GNUInstallDirs) |
| 11 | |
| 12 | include_directories(/usr/local/include;/usr/local/kl/include) |
| 13 | link_directories(/usr/local/kl/lib;/usr/local/lib;/usr/local/lib64) |
| 14 | |
| 15 | find_library(COLLOCATORDB libcollocatordb_static.a REQUIRED) |
| 16 | if (NOT COLLOCATORDB) |
| 17 | message(FATAL_ERROR "No libcollocatordb_static.a found. Please install from https://korap.ids-mannheim.de/gerrit/plugins/gitiles/private/collocatordb") |
| 18 | endif () |
| 19 | |
| 20 | find_library(ROCKSDB librocksdb.a REQUIRED) |
| 21 | if (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") |
| 23 | endif () |
| 24 | |
| 25 | file(GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c) |
| 26 | foreach (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 () |
| 35 | endforeach (mysourcefile ${APP_SOURCES}) |
Marc Kupietz | 31e2e31 | 2021-03-22 17:22:57 +0100 | [diff] [blame] | 36 | |
| 37 | enable_testing() |
| 38 | find_program(BASH_PROGRAM bash) |
| 39 | if (BASH_PROGRAM) |
| 40 | add_test(type-3-test ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test-type-3.sh) |
| 41 | else () |
| 42 | message(SEND_ERROR "Cannot find bash, needed for testing") |
| 43 | endif () |