Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ fserv.includes
debug/
release/
scratch-space/

src/cmake_config.hpp

CMakeCache.txt
CMakeFiles
CMakeScripts
Makefile
*.cmake
install_manifest.txt
/cotire
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "cmake_modules/cotire"]
path = cmake_modules/cotire
url = https://github.com/sakra/cotire.git
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
language: cpp
compiler: clang
dist: trusty

before-install:
- sudo apt-get update

install:
- sudo apt-get install libev-dev libgoogle-perftools-dev libhiredis-dev libicu-dev libcurl4-openssl-dev libboost-dev libluajit-5.1-dev libpth-dev uuid-dev
- sudo apt-get install -qq libev-dev libgoogle-perftools-dev libhiredis-dev libicu-dev libcurl4-openssl-dev libboost-dev libluajit-5.1-dev libpth-dev uuid-dev

# Get libjansson version 2.5, the one in Ubuntu 12.04's repos is way outdated.
- cd ~/build
Expand All @@ -23,13 +24,15 @@ install:

# Fetch and build evHTTPClient
- cd ~/build
- git clone https://github.com/jspotter/evhttpclient
- git clone https://github.com/larsven/evhttpclient
- cd evhttpclient
- make
- sudo cp *.h /usr/include
- sudo cp libevhttpclient.so /usr/lib

script:
# Finally, build fserv.
- cd ~/build/f-list/fserv
- make all
- cd $HOME/build/$TRAVIS_REPO_SLUG
- mkdir build && cd build
- cmake ..
- make
118 changes: 118 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
cmake_minimum_required(VERSION 2.8.7)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")


## compiler flags

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing -Werror")


project(fserv)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY release)

find_package(Threads REQUIRED)

find_package(LibEV REQUIRED)
find_package(LuaJIT REQUIRED)
find_package(Glog REQUIRED)
find_package(tcmalloc REQUIRED)
find_package(libjansson REQUIRED)
find_package(Hiredis REQUIRED)
find_package(ICU REQUIRED)
find_package(CURL REQUIRED)
find_package(Evhttpclient REQUIRED)
find_package(Boost REQUIRED)

include_directories(
"${LUAJIT_INCLUDE_DIR}"
"${LIBEV_INCLUDE_DIR}"
"${GLOG_INCLUDE_DIR}"
"${Tcmalloc_INCLUDE_DIR}"
"${JANSSON_INCLUDE_DIR}"
"${LIBHIREDIS_INCLUDE_DIR}"
"${ICU_INCLUDE_DIRS}"
"${CURL_INCLUDE_DIR}"
"${EVHTTPCLIENT_INCLUDE_DIR}"
"${Boost_INCLUDE_DIRS}")


## compatibility for pre-2.0 gperftools

find_file(HAVE_NEW_TCMALLOC gperftools/malloc_extension.h ${Tcmalloc_INCLUDE_DIR} NO_DEFAULT_PATH)


## generate the build config file

configure_file(src/cmake_config.hpp.in "${CMAKE_SOURCE_DIR}/src/cmake_config.hpp")


## fserv binary

set(fserv_SOURCES
src/channel.cpp
src/connection.cpp
src/fserv.cpp
src/login_evhttp.cpp
src/lua_channel.cpp
src/lua_chat.cpp
src/lua_connection.cpp
src/lua_constants.cpp
src/messagebuffer.cpp
src/native_command.cpp
src/redis.cpp
src/server.cpp
src/server_state.cpp
src/startup_config.cpp
src/unicode_tools.cpp
src/websocket.cpp
src/base64.cpp
src/md5.cpp
src/modp_b64.cpp
src/sha1.cpp)

set(fserv_LIBS ${fserv_LIBS}
"${CMAKE_THREAD_LIBS_INIT}"
"${LUAJIT_LIBRARIES}"
"${LIBEV_LIBRARIES}"
"${GLOG_LIBRARY}"
"${Tcmalloc_LIBRARY}"
"${JANSSON_LIBRARY}"
"${LIBHIREDIS_LIBRARIES}"
"${ICU_LIBRARIES}"
"${CURL_LIBRARY}"
"${EVHTTPCLIENT_LIBRARY}")

add_executable(fserv ${fserv_SOURCES})
target_link_libraries(fserv ${fserv_LIBS})

if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/cmake_modules/cotire/CMake")
message("## Found cotire; using precompiled header")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/cotire/CMake")
include(cotire)
set_target_properties(fserv PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "src/precompiled_headers.hpp")
cotire(fserv)
else()
message("## Could not find cotire; not using precompiled header")
message("## If you've cloned from git, run `git submodule init && git submodule update` to fetch cotire")
endif()


## facceptor binary

set(facceptor_SOURCES
src/facceptor.cpp)

set(facceptor_LIBS
"${LIBEV_LIBRARIES}")

add_executable(facceptor ${facceptor_SOURCES})
target_link_libraries(facceptor ${facceptor_LIBS})


## copy scripts over to the release dir
add_custom_command(
TARGET fserv POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/script ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/script

COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/logs)
5 changes: 0 additions & 5 deletions Makefile

This file was deleted.

20 changes: 20 additions & 0 deletions cmake_modules/FindEvhttpclient.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# adapted from Findlibjansson.cmake

find_path(EVHTTPCLIENT_INCLUDE_DIR evhttpclient.h
PATHS /usr/include
)

find_library(EVHTTPCLIENT_LIBRARY
NAMES evhttpclient
PATHS /usr/lib /usr/local/lib
)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(EVHTTPCLIENT
DEFAULT_MSG
EVHTTPCLIENT_INCLUDE_DIR
EVHTTPCLIENT_LIBRARY
)

include_directories(${EVHTTPCLIENT_INCLUDE_DIR})
51 changes: 51 additions & 0 deletions cmake_modules/FindGlog.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# taken from Caffe at https://raw.githubusercontent.com/BVLC/caffe/master/cmake/Modules/FindGlog.cmake
# licensed under the same license as Caffe, https://github.com/BVLC/caffe/blob/master/LICENSE

# - Try to find Glog
#
# The following variables are optionally searched for defaults
# GLOG_ROOT_DIR: Base directory where all GLOG components are found
#
# The following are set after configuration is done:
# GLOG_FOUND
# GLOG_INCLUDE_DIRS
# GLOG_LIBRARIES
# GLOG_LIBRARYRARY_DIRS

include(FindPackageHandleStandardArgs)

set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google glog")

if(WIN32)
find_path(GLOG_INCLUDE_DIR glog/logging.h
PATHS ${GLOG_ROOT_DIR}/src/windows)
else()
find_path(GLOG_INCLUDE_DIR glog/logging.h
PATHS ${GLOG_ROOT_DIR})
endif()

if(MSVC)
find_library(GLOG_LIBRARY_RELEASE libglog_static
PATHS ${GLOG_ROOT_DIR}
PATH_SUFFIXES Release)

find_library(GLOG_LIBRARY_DEBUG libglog_static
PATHS ${GLOG_ROOT_DIR}
PATH_SUFFIXES Debug)

set(GLOG_LIBRARY optimized ${GLOG_LIBRARY_RELEASE} debug ${GLOG_LIBRARY_DEBUG})
else()
find_library(GLOG_LIBRARY glog
PATHS ${GLOG_ROOT_DIR}
PATH_SUFFIXES lib lib64)
endif()

find_package_handle_standard_args(Glog DEFAULT_MSG GLOG_INCLUDE_DIR GLOG_LIBRARY)

if(GLOG_FOUND)
set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
set(GLOG_LIBRARIES ${GLOG_LIBRARY})
message(STATUS "Found glog (include: ${GLOG_INCLUDE_DIR}, library: ${GLOG_LIBRARY})")
mark_as_advanced(GLOG_ROOT_DIR GLOG_LIBRARY_RELEASE GLOG_LIBRARY_DEBUG
GLOG_LIBRARY GLOG_INCLUDE_DIR)
endif()
35 changes: 35 additions & 0 deletions cmake_modules/FindHiredis.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# taken from https://github.com/libgit2/libgit2-backends/blob/master/CMake/FindHiredis.cmake
# license unknown

# - Try to find the Lib library
# Once done this will define
#
# LIBHIREDIS_FOUND - System has Hiredis
# LIBHIREDIS_INCLUDE_DIR - The Hiredis include directory
# LIBHIREDIS_LIBRARIES - The libraries needed to use Hiredis
# LIBHIREDIS_DEFINITIONS - Compiler switches required for using Hiredis


# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
#FIND_PACKAGE(PkgConfig)
#PKG_SEARCH_MODULE(PC_LIBHIREDIS libhiredis)

SET(LIBHIREDIS_DEFINITIONS ${PC_LIBHIREDIS_CFLAGS_OTHER})

FIND_PATH(LIBHIREDIS_INCLUDE_DIR hiredis/hiredis.h
HINTS
${PC_LIBHIREDIS_INCLUDEDIR}
${PC_LIBHIREDIS_INCLUDE_DIRS}
)

FIND_LIBRARY(LIBHIREDIS_LIBRARIES NAMES hiredis
HINTS
${PC_LIBHIREDIS_LIBDIR}
${PC_LIBHIREDIS_LIBRARY_DIRS}
)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibHiredis DEFAULT_MSG LIBHIREDIS_LIBRARIES LIBHIREDIS_INCLUDE_DIR)

#MARK_AS_ADVANCED(LIBHIREDIS_INCLUDE_DIR LIBHIREDIS_LIBRARIES)
Loading