concordia-server/CMakeLists.txt
2019-06-27 12:54:16 +02:00

257 lines
8.4 KiB
CMake

# Tutorial: http://www.cmake.org/cmake/help/cmake_tutorial.html
cmake_minimum_required(VERSION 2.6)
project(concordia-server CXX)
set (CONCORDIA_SERVER_VERSION_MAJOR 1)
set (CONCORDIA_SERVER_VERSION_MINOR 0)
set(BASE_TARGETS concordia-server)
# ================================================
# Functional settings
# ================================================
set (STOP_WORDS_ENABLED "false")
set (UNIX_USER $ENV{USER})
# ================================================
# Config
# ================================================
set (INDEX_DIRECTORY "${concordia-server_SOURCE_DIR}/index")
set (RESOURCES_DIRECTORY "${concordia-server_SOURCE_DIR}/resources")
configure_file (
"${concordia-server_SOURCE_DIR}/concordia.cfg.in"
"${concordia-server_SOURCE_DIR}/concordia.cfg"
)
set(COMPILED_BINARIES_PATH "${concordia-server_SOURCE_DIR}/build/concordia-server")
set(LEMMAGEN_BINARIES_PATH "${concordia-server_SOURCE_DIR}/LemmaGenSockets/LemmaGenSockets/bin/Debug")
set(SCRIPTS_PATH "${concordia-server_SOURCE_DIR}/scripts")
configure_file (
"${concordia-server_SOURCE_DIR}/scripts/cmake_stubs/start.sh.in"
"${concordia-server_SOURCE_DIR}/scripts/start.sh"
)
configure_file (
"${concordia-server_SOURCE_DIR}/scripts/cmake_stubs/simplestart.sh.in"
"${concordia-server_SOURCE_DIR}/scripts/simplestart.sh"
)
configure_file (
"${concordia-server_SOURCE_DIR}/scripts/cmake_stubs/backgroundstart.sh.in"
"${concordia-server_SOURCE_DIR}/scripts/backgroundstart.sh"
)
configure_file (
"${concordia-server_SOURCE_DIR}/scripts/cmake_stubs/stop.sh.in"
"${concordia-server_SOURCE_DIR}/scripts/stop.sh"
)
configure_file (
"${concordia-server_SOURCE_DIR}/scripts/cmake_stubs/restart.sh.in"
"${concordia-server_SOURCE_DIR}/scripts/restart.sh"
)
configure_file (
"${concordia-server_SOURCE_DIR}/scripts/cmake_stubs/watchdog.sh.in"
"${concordia-server_SOURCE_DIR}/scripts/watchdog.sh"
)
configure_file (
"${concordia-server_SOURCE_DIR}/upstart/cmake_stubs/concordia-server.conf.in"
"${concordia-server_SOURCE_DIR}/upstart/concordia-server.conf"
)
configure_file (
"${concordia-server_SOURCE_DIR}/upstart/cmake_stubs/pgbouncer.conf.in"
"${concordia-server_SOURCE_DIR}/upstart/pgbouncer.conf"
)
configure_file (
"${concordia-server_SOURCE_DIR}/upstart/cmake_stubs/lemmagen.conf.in"
"${concordia-server_SOURCE_DIR}/upstart/lemmagen.conf"
)
configure_file (
"${concordia-server_SOURCE_DIR}/db/pgbouncer.ini.in"
"${concordia-server_SOURCE_DIR}/db/pgbouncer.ini"
)
set(CONFIG_FILE_PATH "${concordia-server_SOURCE_DIR}/concordia.cfg")
set(LOG_FILE_PATH "${concordia-server_SOURCE_DIR}/logs/concordia-server.log")
set(PHRASE_LOG_FILE_PATH "${concordia-server_SOURCE_DIR}/logs/phrase-searches.json")
# --------------
# db settings
# --------------
set (DB_NAME "concordia_db")
set (DB_USER "concordia")
set (DB_PASSWORD "concordia")
set (DB_HOST "concordia-postgres")
set (DB_PORT "5432")
configure_file (
"${concordia-server_SOURCE_DIR}/concordia-server/config.hpp.in"
"${concordia-server_SOURCE_DIR}/concordia-server/config.hpp"
)
# ================================================
# Third-party libraries
# ================================================
# ----------------------------------------------------
# Regular expression libraries
# ----------------------------------------------------
option(WITH_RE2 "Using RE2 regular expression library" OFF)
message(STATUS "Using RE2 regular expression library ${WITH_RE2}")
if(WITH_RE2)
set(HAVE_RE2 1)
endif(WITH_RE2)
option(WITH_PCRE "Using PCRE regular expression library" ON)
message(STATUS "Using PCRE regular expression library ${WITH_PCRE}")
if(WITH_PCRE)
set(HAVE_PCRE 1)
endif(WITH_PCRE)
# ----------------------------------------------------
# ICU (I feeeeel youuuuu...)
# ----------------------------------------------------
find_library(ICU_LIB NAMES icui18n)
find_path(ICU_INCLUDE unicode)
if(EXISTS ${ICU_LIB} AND EXISTS ${ICU_INCLUDE})
message(STATUS "Found ICU: ${ICU_LIB}")
include_directories(${ICU_INCLUDE})
link_directories(${ICU_LIB})
else()
message(FATAL_ERROR "ICU not found")
endif(EXISTS ${ICU_LIB} AND EXISTS ${ICU_INCLUDE})
# ----------------------------------------------------
# Boost
# ----------------------------------------------------
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS
serialization unit_test_framework system filesystem program_options iostreams regex locale REQUIRED)
# ----------------------------------------------------
# libconfig
# ----------------------------------------------------
find_library(LIBCONFIG_LIB NAMES config++ REQUIRED)
find_path(LIBCONFIG_INCLUDE libconfig.h++)
if(EXISTS ${LIBCONFIG_LIB} AND EXISTS ${LIBCONFIG_INCLUDE})
message(STATUS "Found Libconfig")
include_directories(${LIBCONFIG_INCLUDE})
link_directories(${LIBCONFIG_LIB})
endif(EXISTS ${LIBCONFIG_LIB} AND EXISTS ${LIBCONFIG_INCLUDE})
# ----------------------------------------------------
# restclient-cpp
# ----------------------------------------------------
find_library(RESTCLIENT_CPP_LIB NAMES restclient-cpp REQUIRED)
find_path(RESTCLIENT_CPP_INCLUDE restclient-cpp)
if(EXISTS ${RESTCLIENT_CPP_LIB} AND EXISTS ${RESTCLIENT_CPP_INCLUDE})
message(STATUS "Found restclient-cpp")
include_directories(${RESTCLIENT_CPP_INCLUDE})
link_directories(${RESTCLIENT_CPP_LIB})
endif(EXISTS ${RESTCLIENT_CPP_LIB} AND EXISTS ${RESTCLIENT_CPP_INCLUDE})
# ----------------------------------------------------
# curl
# ----------------------------------------------------
find_library(CURL_LIB NAMES curl REQUIRED)
find_path(CURL_INCLUDE curl)
if(EXISTS ${CURL_LIB} AND EXISTS ${CURL_INCLUDE})
message(STATUS "Found curl")
include_directories(${CURL_INCLUDE})
link_directories(${CURL_LIB})
endif(EXISTS ${CURL_LIB} AND EXISTS ${CURL_INCLUDE})
# ----------------------------------------------------
# Logging
# ----------------------------------------------------
find_library(LOG4CPP_LIB NAMES log4cpp REQUIRED)
find_path(LOG4CPP_INCLUDE log4cpp/Appender.hh)
if(EXISTS ${LOG4CPP_LIB} AND EXISTS ${LOG4CPP_INCLUDE})
message(STATUS "Found Log4cpp")
include_directories(${LOG4CPP_INCLUDE})
link_directories(${LOG4CPP_LIB})
endif(EXISTS ${LOG4CPP_LIB} AND EXISTS ${LOG4CPP_INCLUDE})
# ----------------------------------------------------
# FastCGI
# ----------------------------------------------------
find_library(FASTCGI_LIB NAMES fcgi REQUIRED)
if(EXISTS ${FASTCGI_LIB})
message(STATUS "Found fastcgi")
link_directories(${FASTCGI_LIB})
endif(EXISTS ${FASTCGI_LIB})
# ----------------------------------------------------
# FastCGI++
# ----------------------------------------------------
find_library(FASTCGIPP_LIB NAMES fcgi++ REQUIRED)
if(EXISTS ${FASTCGIPP_LIB})
message(STATUS "Found fastcgi++")
link_directories(${FASTCGIPP_LIB})
endif(EXISTS ${FASTCGIPP_LIB})
# ----------------------------------------------------
# libpq
# ----------------------------------------------------
find_library(PQ_LIB NAMES pq REQUIRED)
find_path(PQ_INCLUDE libpq-fe.h HINTS "/usr/include/postgresql")
if(EXISTS ${PQ_LIB})
message(STATUS "Found libpq")
include_directories(${PQ_INCLUDE})
link_directories(${PQ_LIB})
endif(EXISTS ${PQ_LIB})
# ----------------------------------------------------
# Concordia
# ----------------------------------------------------
find_library(CONCORDIA_LIB NAMES conconrdia REQUIRED)
find_path(CONCORDIA_INCLUDE concordia.hpp)
if(EXISTS ${CONCORDIA_LIB} AND EXISTS ${CONCORDIA_INCLUDE})
message(STATUS "Found Concordia")
include_directories(${CONCORDIA_INCLUDE})
link_directories(${CONCORDIA_LIB})
endif(EXISTS ${CONCORDIA_LIB} AND EXISTS ${CONCORDIA_INCLUDE})
# ----------------------------------------------------
# divsufsort
# ----------------------------------------------------
find_library(DIVSUFSORT_LIB NAMES divsufsort REQUIRED)
find_path(DIVSUFSORT_INCLUDE divsufsort.h)
if(EXISTS ${DIVSUFSORT_LIB} AND EXISTS ${DIVSUFSORT_INCLUDE})
message(STATUS "Found divsufsort")
include_directories(${DIVSUFSORT_INCLUDE})
link_directories(${DIVSUFSORT_LIB})
endif(EXISTS ${DIVSUFSORT_LIB} AND EXISTS ${DIVSUFSORT_INCLUDE})
# ----------------------------------------------------
# utf8case
# ----------------------------------------------------
find_library(UTF8CASE_LIB NAMES utf8case REQUIRED)
if(EXISTS ${UTF8CASE_LIB})
message(STATUS "Found utf8case")
link_directories(${UTF8CASE_LIB})
endif(EXISTS ${UTF8CASE_LIB})
add_subdirectory(concordia-server)