2012-10-02 13:49:27 +00:00
|
|
|
##
|
|
|
|
## Makefile for uhub
|
2013-03-22 19:00:40 +00:00
|
|
|
## Copyright (C) 2007-2013, Jan Vidar Krey <janvidar@extatic.org>
|
2012-10-02 13:49:27 +00:00
|
|
|
#
|
|
|
|
|
2012-11-20 21:53:27 +00:00
|
|
|
cmake_minimum_required (VERSION 2.8.2)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
2012-10-02 21:01:57 +00:00
|
|
|
project (uhub NONE)
|
|
|
|
enable_language(C)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
set (UHUB_VERSION_MAJOR 0)
|
|
|
|
set (UHUB_VERSION_MINOR 4)
|
|
|
|
set (UHUB_VERSION_PATCH 1)
|
|
|
|
|
2012-10-04 21:59:20 +00:00
|
|
|
set (PROJECT_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src")
|
2012-11-20 21:53:27 +00:00
|
|
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
option(RELEASE "Release build, debug build if disabled" ON)
|
2013-02-19 23:28:43 +00:00
|
|
|
option(LOWLEVEL_DEBUG, "Enable low level debug messages." OFF)
|
2012-10-02 13:49:27 +00:00
|
|
|
option(LINK_SUPPORT "Allow hub linking" OFF)
|
|
|
|
option(SSL_SUPPORT "Enable SSL support" ON)
|
2012-10-17 19:02:32 +00:00
|
|
|
option(USE_OPENSSL "Use OpenSSL's SSL support" ON )
|
2012-11-17 15:57:14 +00:00
|
|
|
option(SYSTEMD_SUPPORT "Enable systemd notify and journal logging" OFF)
|
2012-10-02 21:01:57 +00:00
|
|
|
option(ADC_STRESS "Enable the stress tester client" OFF)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
find_package(Git)
|
2012-11-20 21:53:27 +00:00
|
|
|
find_package(Sqlite3)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
2013-02-19 23:28:43 +00:00
|
|
|
include(TestBigEndian)
|
|
|
|
|
|
|
|
TEST_BIG_ENDIAN(BIGENDIAN)
|
|
|
|
if (BIGENDIAN)
|
|
|
|
add_definitions(-DARCH_BIGENDIAN)
|
|
|
|
endif()
|
|
|
|
|
2012-10-02 13:49:27 +00:00
|
|
|
if (SSL_SUPPORT)
|
2012-10-02 21:59:11 +00:00
|
|
|
if (USE_OPENSSL)
|
|
|
|
find_package(OpenSSL)
|
|
|
|
else()
|
|
|
|
find_package(GnuTLS)
|
|
|
|
endif()
|
|
|
|
if (NOT GNUTLS_FOUND AND NOT OPENSSL_FOUND)
|
|
|
|
message(FATAL_ERROR "Neither OpenSSL nor GnuTLS are not found!")
|
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
endif()
|
|
|
|
|
2012-11-11 21:21:00 +00:00
|
|
|
if (SYSTEMD_SUPPORT)
|
|
|
|
INCLUDE(FindPkgConfig)
|
2012-11-17 15:57:14 +00:00
|
|
|
pkg_search_module(SD_DAEMON REQUIRED libsystemd-daemon)
|
|
|
|
pkg_search_module(SD_JOURNAL REQUIRED libsystemd-journal)
|
2012-11-11 21:21:00 +00:00
|
|
|
endif()
|
|
|
|
|
2012-10-02 19:38:45 +00:00
|
|
|
if (MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif()
|
|
|
|
|
2012-10-02 13:49:27 +00:00
|
|
|
include_directories("${PROJECT_SOURCE_DIR}")
|
2012-11-20 21:53:27 +00:00
|
|
|
include_directories(${SQLITE3_INCLUDE_DIRS})
|
2013-04-17 20:40:04 +00:00
|
|
|
link_directories(${SQLITE3_LIBRARY_DIRS})
|
2013-04-15 22:24:42 +00:00
|
|
|
|
2012-10-13 17:11:31 +00:00
|
|
|
file (GLOB uhub_SOURCES ${PROJECT_SOURCE_DIR}/core/*.c)
|
|
|
|
list (REMOVE_ITEM uhub_SOURCES
|
|
|
|
${PROJECT_SOURCE_DIR}/core/gen_config.c
|
|
|
|
${PROJECT_SOURCE_DIR}/core/main.c
|
2012-10-02 13:49:27 +00:00
|
|
|
)
|
|
|
|
|
2012-10-13 17:11:31 +00:00
|
|
|
file (GLOB adc_SOURCES ${PROJECT_SOURCE_DIR}/adc/*.c)
|
|
|
|
file (GLOB network_SOURCES ${PROJECT_SOURCE_DIR}/network/*.c)
|
|
|
|
file (GLOB utils_SOURCES ${PROJECT_SOURCE_DIR}/util/*.c)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
set (adcclient_SOURCES
|
|
|
|
${PROJECT_SOURCE_DIR}/tools/adcclient.c
|
2012-10-02 20:38:51 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/core/ioqueue.c
|
2012-10-02 13:49:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
add_library(adc STATIC ${adc_SOURCES})
|
|
|
|
add_library(network STATIC ${network_SOURCES})
|
|
|
|
add_library(utils STATIC ${utils_SOURCES})
|
2014-05-09 15:52:30 +00:00
|
|
|
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
2012-10-09 20:09:25 +00:00
|
|
|
set_target_properties(utils PROPERTIES COMPILE_FLAGS -fPIC)
|
2012-10-09 20:14:38 +00:00
|
|
|
set_target_properties(network PROPERTIES COMPILE_FLAGS -fPIC)
|
2012-10-09 20:09:25 +00:00
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
add_dependencies(adc utils)
|
|
|
|
add_dependencies(network utils)
|
|
|
|
|
|
|
|
add_executable(uhub ${PROJECT_SOURCE_DIR}/core/main.c ${uhub_SOURCES} )
|
2012-10-25 13:32:04 +00:00
|
|
|
add_executable(test ${CMAKE_SOURCE_DIR}/autotest/test.c ${uhub_SOURCES} )
|
2012-11-20 21:53:27 +00:00
|
|
|
add_executable(uhub-passwd ${PROJECT_SOURCE_DIR}/tools/uhub-passwd.c)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
2012-10-09 20:09:25 +00:00
|
|
|
add_library(mod_example MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_example.c)
|
2012-10-09 20:14:38 +00:00
|
|
|
add_library(mod_welcome MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_welcome.c)
|
|
|
|
add_library(mod_logging MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_logging.c ${PROJECT_SOURCE_DIR}/adc/sid.c)
|
2012-10-09 20:09:25 +00:00
|
|
|
add_library(mod_auth_simple MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_auth_simple.c )
|
|
|
|
add_library(mod_chat_history MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_chat_history.c )
|
2012-10-15 02:38:36 +00:00
|
|
|
add_library(mod_chat_history_sqlite MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_chat_history_sqlite.c )
|
2012-10-09 20:09:25 +00:00
|
|
|
add_library(mod_chat_only MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_chat_only.c)
|
|
|
|
add_library(mod_topic MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_topic.c)
|
2012-11-01 21:07:55 +00:00
|
|
|
add_library(mod_no_guest_downloads MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_no_guest_downloads.c)
|
2012-11-20 21:53:27 +00:00
|
|
|
add_library(mod_auth_sqlite MODULE ${PROJECT_SOURCE_DIR}/plugins/mod_auth_sqlite.c)
|
2012-10-09 20:09:25 +00:00
|
|
|
|
2012-10-02 19:38:45 +00:00
|
|
|
if(WIN32)
|
|
|
|
target_link_libraries(uhub ws2_32)
|
2012-10-25 13:32:04 +00:00
|
|
|
target_link_libraries(test ws2_32)
|
2012-10-02 19:38:45 +00:00
|
|
|
target_link_libraries(mod_logging ws2_32)
|
|
|
|
target_link_libraries(mod_welcome ws2_32)
|
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
set_target_properties(
|
|
|
|
mod_example
|
|
|
|
mod_welcome
|
|
|
|
mod_logging
|
|
|
|
mod_auth_simple
|
2012-11-20 21:53:27 +00:00
|
|
|
mod_auth_sqlite
|
2012-10-02 13:49:27 +00:00
|
|
|
mod_chat_history
|
2012-10-15 02:38:36 +00:00
|
|
|
mod_chat_history_sqlite
|
2012-10-02 13:49:27 +00:00
|
|
|
mod_chat_only
|
2012-11-01 21:07:55 +00:00
|
|
|
mod_no_guest_downloads
|
2012-10-02 13:49:27 +00:00
|
|
|
mod_topic
|
|
|
|
PROPERTIES PREFIX "")
|
|
|
|
|
|
|
|
target_link_libraries(uhub ${CMAKE_DL_LIBS} adc network utils)
|
2012-11-20 21:53:27 +00:00
|
|
|
target_link_libraries(uhub-passwd ${SQLITE3_LIBRARIES} utils)
|
2012-10-25 13:32:04 +00:00
|
|
|
target_link_libraries(test ${CMAKE_DL_LIBS} adc network utils)
|
2012-10-09 20:09:25 +00:00
|
|
|
target_link_libraries(mod_example utils)
|
|
|
|
target_link_libraries(mod_welcome utils)
|
|
|
|
target_link_libraries(mod_auth_simple utils)
|
2012-11-20 21:53:27 +00:00
|
|
|
target_link_libraries(mod_auth_sqlite ${SQLITE3_LIBRARIES} utils)
|
2012-10-09 20:09:25 +00:00
|
|
|
target_link_libraries(mod_chat_history utils)
|
2012-10-15 02:38:36 +00:00
|
|
|
target_link_libraries(mod_chat_history_sqlite ${SQLITE3_LIBRARIES} utils)
|
2012-11-01 21:07:55 +00:00
|
|
|
target_link_libraries(mod_no_guest_downloads utils)
|
2012-10-09 20:09:25 +00:00
|
|
|
target_link_libraries(mod_chat_only utils)
|
|
|
|
target_link_libraries(mod_logging utils)
|
|
|
|
target_link_libraries(mod_topic utils)
|
2012-10-24 22:44:21 +00:00
|
|
|
target_link_libraries(utils network)
|
2012-10-09 20:14:38 +00:00
|
|
|
target_link_libraries(mod_welcome network)
|
|
|
|
target_link_libraries(mod_logging network)
|
2012-10-02 13:49:27 +00:00
|
|
|
|
2012-11-20 21:53:27 +00:00
|
|
|
|
2012-10-02 19:38:45 +00:00
|
|
|
if(UNIX)
|
|
|
|
add_library(adcclient STATIC ${adcclient_SOURCES})
|
2012-10-02 21:01:57 +00:00
|
|
|
add_executable(uhub-admin ${PROJECT_SOURCE_DIR}/tools/admin.c)
|
2012-10-24 21:19:14 +00:00
|
|
|
target_link_libraries(uhub-admin adcclient adc network utils pthread)
|
|
|
|
target_link_libraries(uhub pthread)
|
2012-10-25 13:32:04 +00:00
|
|
|
target_link_libraries(test pthread)
|
2012-10-02 21:01:57 +00:00
|
|
|
|
|
|
|
if (ADC_STRESS)
|
|
|
|
add_executable(adcrush ${PROJECT_SOURCE_DIR}/tools/adcrush.c ${adcclient_SOURCES})
|
2012-10-24 21:19:14 +00:00
|
|
|
target_link_libraries(adcrush adcclient adc network utils pthread)
|
2012-10-02 21:01:57 +00:00
|
|
|
endif()
|
2012-10-02 19:38:45 +00:00
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
|
2012-10-13 16:10:16 +00:00
|
|
|
if (NOT UHUB_REVISION AND GIT_FOUND)
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --pretty=format:%h
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE UHUB_REVISION_TEMP
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
if (UHUB_REVISION_TEMP)
|
|
|
|
set (UHUB_REVISION "git-${UHUB_REVISION_TEMP}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT UHUB_REVISION)
|
|
|
|
set (UHUB_REVISION "release")
|
2012-10-02 13:49:27 +00:00
|
|
|
endif()
|
|
|
|
|
2012-10-13 16:10:16 +00:00
|
|
|
set (UHUB_GIT_VERSION "${UHUB_VERSION_MAJOR}.${UHUB_VERSION_MINOR}.${UHUB_VERSION_PATCH}-${UHUB_REVISION}")
|
2012-10-15 18:27:43 +00:00
|
|
|
message (STATUS "Configuring uhub version: ${UHUB_GIT_VERSION}")
|
2012-10-13 16:10:16 +00:00
|
|
|
|
2012-10-02 13:49:27 +00:00
|
|
|
if(OPENSSL_FOUND)
|
2012-10-02 21:59:11 +00:00
|
|
|
set(SSL_LIBS ${OPENSSL_LIBRARIES})
|
|
|
|
add_definitions(-DSSL_SUPPORT=1 -DSSL_USE_OPENSSL=1)
|
2012-10-02 13:49:27 +00:00
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
2012-10-02 21:59:11 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (GNUTLS_FOUND)
|
|
|
|
set(SSL_LIBS ${GNUTLS_LIBRARIES})
|
|
|
|
add_definitions(-DSSL_SUPPORT=1 -DSSL_USE_GNUTLS=1 ${GNUTLS_DEFINITIONS})
|
|
|
|
include_directories(${GNUTLS_INCLUDE_DIR})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(SSL_SUPPORT)
|
|
|
|
target_link_libraries(uhub ${SSL_LIBS})
|
2012-10-25 13:32:04 +00:00
|
|
|
target_link_libraries(test ${SSL_LIBS})
|
2012-10-02 19:38:45 +00:00
|
|
|
if(UNIX)
|
2012-10-02 21:59:11 +00:00
|
|
|
target_link_libraries(uhub-admin ${SSL_LIBS})
|
2012-10-02 19:38:45 +00:00
|
|
|
endif()
|
2012-10-02 21:59:11 +00:00
|
|
|
target_link_libraries(mod_welcome ${SSL_LIBS})
|
|
|
|
target_link_libraries(mod_logging ${SSL_LIBS})
|
2012-10-02 21:59:11 +00:00
|
|
|
if (ADC_STRESS)
|
2012-10-02 21:59:11 +00:00
|
|
|
target_link_libraries(adcrush ${SSL_LIBS})
|
2012-10-02 21:59:11 +00:00
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
endif()
|
|
|
|
|
2012-11-11 21:21:00 +00:00
|
|
|
if (SYSTEMD_SUPPORT)
|
2012-11-17 15:57:14 +00:00
|
|
|
target_link_libraries(uhub ${SD_DAEMON_LIBRARIES})
|
|
|
|
target_link_libraries(uhub ${SD_JOURNAL_LIBRARIES})
|
|
|
|
target_link_libraries(test ${SD_DAEMON_LIBRARIES})
|
|
|
|
target_link_libraries(test ${SD_JOURNAL_LIBRARIES})
|
|
|
|
target_link_libraries(uhub-passwd ${SD_JOURNAL_LIBRARIES})
|
|
|
|
target_link_libraries(uhub-admin ${SD_JOURNAL_LIBRARIES})
|
|
|
|
include_directories(${SD_DAEMON_INCLUDE_DIRS})
|
|
|
|
include_directories(${SD_JOURNAL_INCLUDE_DIRS})
|
2012-11-11 21:21:00 +00:00
|
|
|
add_definitions(-DSYSTEMD)
|
|
|
|
endif()
|
|
|
|
|
2012-10-02 13:49:27 +00:00
|
|
|
configure_file ("${PROJECT_SOURCE_DIR}/version.h.in" "${PROJECT_SOURCE_DIR}/version.h")
|
|
|
|
|
|
|
|
mark_as_advanced(FORCE CMAKE_BUILD_TYPE)
|
|
|
|
if (RELEASE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
2013-02-05 21:44:31 +00:00
|
|
|
add_definitions(-DNDEBUG)
|
2012-10-02 13:49:27 +00:00
|
|
|
else()
|
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
2013-02-19 23:28:43 +00:00
|
|
|
add_definitions(-DDEBUG)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LOWLEVEL_DEBUG)
|
|
|
|
add_definitions(-DLOWLEVEL_DEBUG)
|
2012-10-02 13:49:27 +00:00
|
|
|
endif()
|
|
|
|
|
2012-10-02 21:01:57 +00:00
|
|
|
if (UNIX)
|
2012-11-20 21:53:27 +00:00
|
|
|
install( TARGETS uhub uhub-passwd RUNTIME DESTINATION bin )
|
2013-03-22 19:00:40 +00:00
|
|
|
install( TARGETS mod_example mod_welcome mod_logging mod_auth_simple mod_auth_sqlite mod_chat_history mod_chat_history_sqlite mod_chat_only mod_topic mod_no_guest_downloads DESTINATION /usr/lib/uhub/ OPTIONAL )
|
2012-10-09 17:31:54 +00:00
|
|
|
install( FILES ${CMAKE_SOURCE_DIR}/doc/uhub.conf ${CMAKE_SOURCE_DIR}/doc/plugins.conf ${CMAKE_SOURCE_DIR}/doc/rules.txt ${CMAKE_SOURCE_DIR}/doc/motd.txt DESTINATION /etc/uhub OPTIONAL )
|
2012-10-02 21:01:57 +00:00
|
|
|
endif()
|
2012-10-02 13:49:27 +00:00
|
|
|
|
|
|
|
|