blob: 3baa2d43db57b0e08cb4223d4017e3437e524b08 [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 Kupietz8b169772025-02-10 20:55:47 +01003option(STATIC_DEREKO2VEC "Build dereko2vec as a static binary" OFF)
4
Marc Kupietz6afb3522021-03-22 17:22:55 +01005set(CMAKE_VERBOSE_MAKEFILE on)
Marc Kupietz61485ad2023-12-22 16:16:59 +01006if (CMAKE_BUILD_TYPE MATCHES Debug)
Marc Kupietz8b169772025-02-10 20:55:47 +01007 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 Kupietz61485ad2023-12-22 16:16:59 +01008else ()
Marc Kupietz8b169772025-02-10 20:55:47 +01009 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -march=native -mtune=native -Wall -funroll-loops")
Marc Kupietz61485ad2023-12-22 16:16:59 +010010endif ()
Marc Kupietz8b169772025-02-10 20:55:47 +010011set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} m pthread rt snappy z bz2 lz4 zstd stdc++ dl)
Marc Kupietz6afb3522021-03-22 17:22:55 +010012include(GNUInstallDirs)
13
14include_directories(/usr/local/include;/usr/local/kl/include)
15link_directories(/usr/local/kl/lib;/usr/local/lib;/usr/local/lib64)
16
17find_library(COLLOCATORDB libcollocatordb_static.a REQUIRED)
18if (NOT COLLOCATORDB)
19 message(FATAL_ERROR "No libcollocatordb_static.a found. Please install from https://korap.ids-mannheim.de/gerrit/plugins/gitiles/private/collocatordb")
20endif ()
21
22find_library(ROCKSDB librocksdb.a REQUIRED)
23if (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")
25endif ()
26
27file(GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c)
28foreach (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 Kupietz8b169772025-02-10 20:55:47 +010036 if(STATIC_DEREKO2VEC)
37 set_target_properties(${myname} PROPERTIES LINK_FLAGS "-static")
38 endif()
39 else ()
40 target_link_libraries(${myname} m pthread)
Marc Kupietz6afb3522021-03-22 17:22:55 +010041 endif ()
42endforeach (mysourcefile ${APP_SOURCES})
Marc Kupietz31e2e312021-03-22 17:22:57 +010043
44enable_testing()
45find_program(BASH_PROGRAM bash)
46if (BASH_PROGRAM)
47 add_test(type-3-test ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test-type-3.sh)
48else ()
49 message(SEND_ERROR "Cannot find bash, needed for testing")
50endif ()