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 | 8b16977 | 2025-02-10 20:55:47 +0100 | [diff] [blame^] | 3 | option(STATIC_DEREKO2VEC "Build dereko2vec as a static binary" OFF) |
| 4 | |
Marc Kupietz | 6afb352 | 2021-03-22 17:22:55 +0100 | [diff] [blame] | 5 | set(CMAKE_VERBOSE_MAKEFILE on) |
Marc Kupietz | 61485ad | 2023-12-22 16:16:59 +0100 | [diff] [blame] | 6 | if (CMAKE_BUILD_TYPE MATCHES Debug) |
Marc Kupietz | 8b16977 | 2025-02-10 20:55:47 +0100 | [diff] [blame^] | 7 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -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") |
Marc Kupietz | 61485ad | 2023-12-22 16:16:59 +0100 | [diff] [blame] | 8 | else () |
Marc Kupietz | 8b16977 | 2025-02-10 20:55:47 +0100 | [diff] [blame^] | 9 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -march=native -mtune=native -Wall -funroll-loops") |
Marc Kupietz | 61485ad | 2023-12-22 16:16:59 +0100 | [diff] [blame] | 10 | endif () |
Marc Kupietz | 8b16977 | 2025-02-10 20:55:47 +0100 | [diff] [blame^] | 11 | set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} m pthread rt snappy z bz2 lz4 zstd stdc++ dl) |
Marc Kupietz | 6afb352 | 2021-03-22 17:22:55 +0100 | [diff] [blame] | 12 | include(GNUInstallDirs) |
| 13 | |
| 14 | include_directories(/usr/local/include;/usr/local/kl/include) |
| 15 | link_directories(/usr/local/kl/lib;/usr/local/lib;/usr/local/lib64) |
| 16 | |
| 17 | find_library(COLLOCATORDB libcollocatordb_static.a REQUIRED) |
| 18 | if (NOT COLLOCATORDB) |
| 19 | message(FATAL_ERROR "No libcollocatordb_static.a found. Please install from https://korap.ids-mannheim.de/gerrit/plugins/gitiles/private/collocatordb") |
| 20 | endif () |
| 21 | |
| 22 | find_library(ROCKSDB librocksdb.a REQUIRED) |
| 23 | if (NOT ROCKSDB) |
| 24 | 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") |
| 25 | endif () |
| 26 | |
| 27 | file(GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c) |
| 28 | foreach (mysourcefile ${APP_SOURCES}) |
| 29 | # I used a simple string replace, to cut off .cpp. |
| 30 | string(REPLACE ".c" "" myname ${mysourcefile}) |
| 31 | string(REGEX REPLACE ".*/" "" myname ${myname}) |
| 32 | add_executable(${myname} ${mysourcefile}) |
| 33 | # Make sure YourLib is linked to each app |
| 34 | if (${myname} MATCHES "derek") |
| 35 | target_link_libraries(${myname} ${COLLOCATORDB} ${ROCKSDB} ${ADDITIONAL_LIBS}) |
Marc Kupietz | 8b16977 | 2025-02-10 20:55:47 +0100 | [diff] [blame^] | 36 | if(STATIC_DEREKO2VEC) |
| 37 | set_target_properties(${myname} PROPERTIES LINK_FLAGS "-static") |
| 38 | endif() |
| 39 | else () |
| 40 | target_link_libraries(${myname} m pthread) |
Marc Kupietz | 6afb352 | 2021-03-22 17:22:55 +0100 | [diff] [blame] | 41 | endif () |
| 42 | endforeach (mysourcefile ${APP_SOURCES}) |
Marc Kupietz | 31e2e31 | 2021-03-22 17:22:57 +0100 | [diff] [blame] | 43 | |
| 44 | enable_testing() |
| 45 | find_program(BASH_PROGRAM bash) |
| 46 | if (BASH_PROGRAM) |
| 47 | add_test(type-3-test ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test-type-3.sh) |
| 48 | else () |
| 49 | message(SEND_ERROR "Cannot find bash, needed for testing") |
| 50 | endif () |