Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
windoze committed Jan 13, 2017
1 parent 9bc5bc9 commit 58bb7ce
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 199 deletions.
138 changes: 68 additions & 70 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,83 +1,81 @@
cmake_minimum_required(VERSION 2.8)
project(fibio)

option(WITH_CXX17 "Build with C++1z/17 support" OFF)
option(WITH_REDIS "Build Redis library" ON)
option(WITH_HTTP "Build HTTP library" ON)
option(WITH_THRIFT "Build Thrift tests" ON)
option(WITH_MYSQL "Build MySQL library" ON)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(fibio)

OPTION(WITH_CXX17 "Build with C++1z/17 support" OFF)
OPTION(WITH_REDIS "Build Redis library" ON)
OPTION(WITH_HTTP "Build HTTP library" ON)
OPTION(WITH_THRIFT "Build Thrift tests" ON)
OPTION(WITH_MYSQL "Build MySQL library" ON)
OPTION(WITH_CASSANDRA "Build Cassandra library" ON)
option(WITH_VALGRIND "Build with valgrind support" ON)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set (CMAKE_CXX_STANDARD 14)
if(WITH_CXX17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -ftemplate-depth=256")
else(WITH_CXX17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -ftemplate-depth=256")
endif(WITH_CXX17)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-deprecated-register -Wno-macro-redefined")
set(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} -stdlib=libc++")
endif(APPLE)

find_package(Threads REQUIRED)
find_package(Boost 1.63.0 COMPONENTS system coroutine context thread REQUIRED)
find_package(OpenSSL REQUIRED)

IF((CMAKE_BUILD_TYPE MATCHES Debug) OR (NOT CMAKE_BUILD_TYPE))
IF(WITH_VALGRIND)
message("Enable valgrind support")
add_definitions(-DHAVE_VALGRIND_H)
ELSE(WITH_VALGRIND)
message("Disable valgrind support")
ENDIF(WITH_VALGRIND)
ENDIF((CMAKE_BUILD_TYPE MATCHES Debug) OR (NOT CMAKE_BUILD_TYPE))
OPTION(WITH_VALGRIND "Build with valgrind support" ON)

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
SET(CMAKE_CXX_STANDARD 14)
IF (WITH_CXX17)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -ftemplate-depth=256")
ENDIF (WITH_CXX17)
IF (APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-deprecated-register -Wno-macro-redefined")
SET(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} -stdlib=libc++")
ENDIF (APPLE)

FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(Boost 1.63.0 COMPONENTS system coroutine context thread REQUIRED)
FIND_PACKAGE(OpenSSL REQUIRED)

IF ((CMAKE_BUILD_TYPE MATCHES Debug) OR (NOT CMAKE_BUILD_TYPE))
IF (WITH_VALGRIND)
MESSAGE("Enable valgrind support")
ADD_DEFINITIONS(-DHAVE_VALGRIND_H)
ELSE (WITH_VALGRIND)
MESSAGE("Disable valgrind support")
ENDIF (WITH_VALGRIND)
ENDIF ((CMAKE_BUILD_TYPE MATCHES Debug) OR (NOT CMAKE_BUILD_TYPE))

INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})

set(FIBIO_DEPS)
list(APPEND FIBIO_DEPS fibio ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
SET(FIBIO_DEPS)
LIST(APPEND FIBIO_DEPS fibio ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

set(FIBIO_DEPS_INCS)
list(APPEND FIBIO_DEPS_INCS ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
SET(FIBIO_DEPS_INCS)
LIST(APPEND FIBIO_DEPS_INCS ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})

find_package(ZLIB)
find_package(Boost 1.63.0 COMPONENTS iostreams)
IF(ZLIB_FOUND AND Boost_FOUND)
add_definitions(-DHAVE_ZLIB)
INCLUDE_DIRECTORIES(AFTER ${ZLIB_INCLUDE_DIR})
list(APPEND FIBIO_DEPS ${ZLIB_LIBRARIES})
list(APPEND FIBIO_DEPS ${Boost_LIBRARIES})
list(APPEND FIBIO_DEPS_INCS ${ZLIB_INCLUDE_DIR})
ENDIF(ZLIB_FOUND AND Boost_FOUND)
FIND_PACKAGE(ZLIB)
FIND_PACKAGE(Boost 1.63.0 COMPONENTS iostreams)
IF (ZLIB_FOUND AND Boost_FOUND)
ADD_DEFINITIONS(-DHAVE_ZLIB)
INCLUDE_DIRECTORIES(AFTER ${ZLIB_INCLUDE_DIR})
LIST(APPEND FIBIO_DEPS ${ZLIB_LIBRARIES})
LIST(APPEND FIBIO_DEPS ${Boost_LIBRARIES})
LIST(APPEND FIBIO_DEPS_INCS ${ZLIB_INCLUDE_DIR})
ENDIF (ZLIB_FOUND AND Boost_FOUND)

INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/include)

IF(WIN32)
list(APPEND FIBIO_DEPS wsock32 ws2_32)
ENDIF(WIN32)

IF(WITH_MYSQL)
find_package(MySQLConnectorCPP)
IF(MYSQLCONNECTORCPP_FOUND)
INCLUDE_DIRECTORIES(AFTER ${MYSQLCONNECTORCPP_INCLUDE_DIRS})
list(APPEND FIBIO_DEPS ${MYSQLCONNECTORCPP_LIBRARIES})
list(APPEND FIBIO_DEPS_INCS ${MYSQLCONNECTORCPP_INCLUDE_DIRS})
ELSE(MYSQLCONNECTORCPP_FOUND)
message("MySQL Connector/C++ is not found, disable MySQL support")
ENDIF(MYSQLCONNECTORCPP_FOUND)
ENDIF(WITH_MYSQL)
IF (WIN32)
LIST(APPEND FIBIO_DEPS wsock32 ws2_32)
ENDIF (WIN32)

IF (WITH_MYSQL)
FIND_PACKAGE(MySQLConnectorCPP)
IF (MYSQLCONNECTORCPP_FOUND)
INCLUDE_DIRECTORIES(AFTER ${MYSQLCONNECTORCPP_INCLUDE_DIRS})
LIST(APPEND FIBIO_DEPS ${MYSQLCONNECTORCPP_LIBRARIES})
LIST(APPEND FIBIO_DEPS_INCS ${MYSQLCONNECTORCPP_INCLUDE_DIRS})
ELSE (MYSQLCONNECTORCPP_FOUND)
MESSAGE("MySQL Connector/C++ is not found, disable MySQL support")
ENDIF (MYSQLCONNECTORCPP_FOUND)
ENDIF (WITH_MYSQL)

IF (WITH_CASSANDRA)
FIND_PACKAGE(CassandraDriver)
IF (CASSANDRADRIVER_FOUND)
INCLUDE_DIRECTORIES(AFTER ${CASSANDRADRIVER_INCLUDE_DIRS})
LIST(APPEND FIBIO_DEPS ${CASSANDRADRIVER_LIBRARIES})
LIST(APPEND FIBIO_DEPS_INCS ${CASSANDRADRIVER_INCLUDE_DIRS})
ELSE (CASSANDRADRIVER_FOUND)
MESSAGE("Cassandra C/C++ driver is not found, disable Cassandra support")
ENDIF (CASSANDRADRIVER_FOUND)
FIND_PACKAGE(CassandraDriver)
IF (CASSANDRADRIVER_FOUND)
INCLUDE_DIRECTORIES(AFTER ${CASSANDRADRIVER_INCLUDE_DIRS})
LIST(APPEND FIBIO_DEPS ${CASSANDRADRIVER_LIBRARIES})
LIST(APPEND FIBIO_DEPS_INCS ${CASSANDRADRIVER_INCLUDE_DIRS})
ELSE (CASSANDRADRIVER_FOUND)
MESSAGE("Cassandra C/C++ driver is not found, disable Cassandra support")
ENDIF (CASSANDRADRIVER_FOUND)
ENDIF (WITH_CASSANDRA)

SET(FIBIO_LIBS fibio ${FIBIO_DEPS})
Expand All @@ -88,4 +86,4 @@ ADD_SUBDIRECTORY(example)

INCLUDE("CPackLists.txt")

enable_testing()
ENABLE_TESTING()
2 changes: 1 addition & 1 deletion CPackLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
SET(CPACK_DEBIAN_PACKAGE_NAME "libfibio-dev")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/windoze/fibio")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-coroutine-dev (>=1.56), libboost-context-dev (>=1.56), libboost-system-dev (>=1.56), libboost-iostreams-dev (>=1.56), libboost-thread-dev (>=1.56), libssl-dev, zlib1g-dev")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-coroutine-dev (>=1.63), libboost-context-dev (>=1.63), libboost-system-dev (>=1.56), libboost-iostreams-dev (>=1.63), libboost-thread-dev (>=1.63), libssl-dev, zlib1g-dev")
INCLUDE(CPack)
44 changes: 22 additions & 22 deletions cmake/Modules/FindMySQLConnectorCPP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
# The user may wish to set, in the CMake GUI or otherwise, this variable:
# MYSQLCONNECTORCPP_ROOT_DIR - path to start searching for the module

set(MYSQLCONNECTORCPP_ROOT_DIR
SET(MYSQLCONNECTORCPP_ROOT_DIR
"${MYSQLCONNECTORCPP_ROOT_DIR}"
CACHE
PATH
"Where to start looking for this component.")

if(WIN32)
find_path(MYSQLCONNECTORCPP_INCLUDE_DIR
IF (WIN32)
FIND_PATH(MYSQLCONNECTORCPP_INCLUDE_DIR
NAMES
mysql_connection.h
PATHS
Expand All @@ -25,7 +25,7 @@ if(WIN32)
PATH_SUFFIXES
include)

find_library(MYSQLCONNECTORCPP_LIBRARY
FIND_LIBRARY(MYSQLCONNECTORCPP_LIBRARY
NAMES
mysqlcppconn
mysqlcppconn-static
Expand All @@ -34,15 +34,15 @@ if(WIN32)
PATH_SUFFIXES
lib)

else()
find_path(MYSQLCONNECTORCPP_INCLUDE_DIR
ELSE ()
FIND_PATH(MYSQLCONNECTORCPP_INCLUDE_DIR
mysql_connection.h
HINTS
${MYSQLCONNECTORCPP_ROOT_DIR}
PATH_SUFFIXES
include)

find_library(MYSQLCONNECTORCPP_LIBRARY
FIND_LIBRARY(MYSQLCONNECTORCPP_LIBRARY
NAMES
mysqlcppconn
mysqlcppconn-static
Expand All @@ -51,23 +51,23 @@ else()
PATH_SUFFIXES
lib64
lib)
endif()
ENDIF ()

mark_as_advanced(MYSQLCONNECTORCPP_INCLUDE_DIR
MYSQLCONNECTORCPP_LIBRARY)
MARK_AS_ADVANCED(MYSQLCONNECTORCPP_INCLUDE_DIR
MYSQLCONNECTORCPP_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MysqlConnectorCpp
DEFAULT_MSG
MYSQLCONNECTORCPP_INCLUDE_DIR
MYSQLCONNECTORCPP_LIBRARY)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MysqlConnectorCpp
DEFAULT_MSG
MYSQLCONNECTORCPP_INCLUDE_DIR
MYSQLCONNECTORCPP_LIBRARY)

if(MYSQLCONNECTORCPP_FOUND)
set(MYSQLCONNECTORCPP_INCLUDE_DIRS
IF (MYSQLCONNECTORCPP_FOUND)
SET(MYSQLCONNECTORCPP_INCLUDE_DIRS
"${MYSQLCONNECTORCPP_INCLUDE_DIR}")
# Add any dependencies here
set(MYSQLCONNECTORCPP_LIBRARIES
# Add any dependencies here
SET(MYSQLCONNECTORCPP_LIBRARIES
"${MYSQLCONNECTORCPP_LIBRARY}")
# Add any dependencies here
mark_as_advanced(MYSQLCONNECTORCPP_ROOT_DIR)
endif()
# Add any dependencies here
MARK_AS_ADVANCED(MYSQLCONNECTORCPP_ROOT_DIR)
ENDIF ()
6 changes: 3 additions & 3 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

add_executable(websocket_echo websocket_echo.cpp)
ADD_EXECUTABLE(websocket_echo websocket_echo.cpp)
TARGET_LINK_LIBRARIES(websocket_echo ${FIBIO_LIBS})

add_executable(echo_server echo_server.cpp)
ADD_EXECUTABLE(echo_server echo_server.cpp)
TARGET_LINK_LIBRARIES(echo_server ${FIBIO_LIBS})

2 changes: 1 addition & 1 deletion include/fibio/fibers/fiber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class fiber
/**
* returns the _id_ of the thread
*/
id get_id() const noexcept;
fiber::id get_id() const noexcept;

/**
* returns the number of concurrent fibers supported by the implementation
Expand Down
60 changes: 30 additions & 30 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

set(HDRS)
set(SRCS)
SET(HDRS)
SET(SRCS)

set(FIBER_HDR
SET(FIBER_HDR
${CMAKE_SOURCE_DIR}/include/fibio/asio.hpp
${CMAKE_SOURCE_DIR}/include/fibio/concurrent/concurrent_queue.hpp
${CMAKE_SOURCE_DIR}/include/fibio/fiber.hpp
Expand Down Expand Up @@ -41,7 +41,7 @@ set(FIBER_HDR
${CMAKE_SOURCE_DIR}/include/fibio/stream/streambuf.hpp
${CMAKE_SOURCE_DIR}/include/fibio/thrift.hpp
${CMAKE_SOURCE_DIR}/include/fibio/utility.hpp)
set(FIBER_SRC
SET(FIBER_SRC
fiber/condition.cpp
fiber/fiber_object.cpp
fiber/fiber_object.hpp
Expand All @@ -50,16 +50,16 @@ set(FIBER_SRC
fiber/scheduler_object.cpp
fiber/scheduler_object.hpp
fiber/stream.cpp)
if((CMAKE_BUILD_TYPE MATCHES Debug) OR (NOT CMAKE_BUILD_TYPE))
list(APPEND SRCS fiber/valgrind/valgrind.h)
endif((CMAKE_BUILD_TYPE MATCHES Debug) OR (NOT CMAKE_BUILD_TYPE))
list(APPEND HDRS ${FIBER_HDR})
list(APPEND SRCS ${FIBER_SRC})
IF((CMAKE_BUILD_TYPE MATCHES Debug) OR (NOT CMAKE_BUILD_TYPE))
LIST(APPEND SRCS fiber/valgrind/valgrind.h)
ENDIF((CMAKE_BUILD_TYPE MATCHES Debug) OR (NOT CMAKE_BUILD_TYPE))
LIST(APPEND HDRS ${FIBER_HDR})
LIST(APPEND SRCS ${FIBER_SRC})

INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/src/fiber)

if(WITH_HTTP)
set(HTTP_HDR
IF(WITH_HTTP)
SET(HTTP_HDR
${CMAKE_SOURCE_DIR}/include/fibio/http/client/client.hpp
${CMAKE_SOURCE_DIR}/include/fibio/http/client/request.hpp
${CMAKE_SOURCE_DIR}/include/fibio/http/client/response.hpp
Expand All @@ -84,35 +84,35 @@ if(WITH_HTTP)
${CMAKE_SOURCE_DIR}/include/fibio/http/server/templates/mustache_template.hpp
${CMAKE_SOURCE_DIR}/include/fibio/http_client.hpp
${CMAKE_SOURCE_DIR}/include/fibio/http_server.hpp)
set(HTTP_SRC
SET(HTTP_SRC
http/chunked_stream.hpp
http/client.cpp
http/common.cpp
http/http_parser_merged.h
http/server.cpp)
list(APPEND HDRS ${HTTP_HDR})
list(APPEND SRCS ${HTTP_SRC})
endif(WITH_HTTP)
LIST(APPEND HDRS ${HTTP_HDR})
LIST(APPEND SRCS ${HTTP_SRC})
ENDIF(WITH_HTTP)

if(WITH_REDIS)
set(REDIS_HDR
IF(WITH_REDIS)
SET(REDIS_HDR
${CMAKE_SOURCE_DIR}/include/fibio/db/redis.hpp
${CMAKE_SOURCE_DIR}/include/fibio/db/redis/client.hpp
${CMAKE_SOURCE_DIR}/include/fibio/db/redis/redis_proto.hpp
)
set(REDIS_SRC
SET(REDIS_SRC
db/redis/client.cpp
db/redis/redis_proto.cpp
)
list(APPEND HDRS ${REDIS_HDR})
list(APPEND SRCS ${REDIS_SRC})
endif(WITH_REDIS)
LIST(APPEND HDRS ${REDIS_HDR})
LIST(APPEND SRCS ${REDIS_SRC})
ENDIF(WITH_REDIS)

if(WITH_MYSQL AND MYSQLCONNECTORCPP_FOUND)
set(MYSQL_HDR
IF(WITH_MYSQL AND MYSQLCONNECTORCPP_FOUND)
SET(MYSQL_HDR
${CMAKE_SOURCE_DIR}/include/fibio/db/mysql.hpp
)
set(MYSQL_SRC
SET(MYSQL_SRC
db/mysql/connection.cpp
db/mysql/connection.hpp
db/mysql/database_metadata.cpp
Expand All @@ -126,9 +126,9 @@ if(WITH_MYSQL AND MYSQLCONNECTORCPP_FOUND)
db/mysql/statement.cpp
db/mysql/statement.hpp
)
list(APPEND HDRS ${MYSQL_HDR})
list(APPEND SRCS ${MYSQL_SRC})
endif(WITH_MYSQL AND MYSQLCONNECTORCPP_FOUND)
LIST(APPEND HDRS ${MYSQL_HDR})
LIST(APPEND SRCS ${MYSQL_SRC})
ENDIF(WITH_MYSQL AND MYSQLCONNECTORCPP_FOUND)

IF (WITH_CASSANDRA AND CASSANDRADRIVER_FOUND)
SET(CASSANDRA_HDR ${CMAKE_SOURCE_DIR}/include/fibio/db/cassandra.hpp)
Expand All @@ -138,10 +138,10 @@ IF (WITH_CASSANDRA AND CASSANDRADRIVER_FOUND)
ENDIF (WITH_CASSANDRA AND CASSANDRADRIVER_FOUND)

ADD_LIBRARY(fibio ${HDRS} ${SRCS})
target_link_libraries(${FIBIO_DEPS})
TARGET_LINK_LIBRARIES(${FIBIO_DEPS})

INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/fibio DESTINATION include
FILES_MATCHING PATTERN "[a-z]*.hpp")
INSTALL (TARGETS fibio EXPORT fibio-targets DESTINATION lib/fibio)
INSTALL(TARGETS fibio EXPORT fibio-targets DESTINATION lib/fibio)
INSTALL(EXPORT fibio-targets DESTINATION lib/fibio)
INSTALL(FILES fibio-config.cmake DESTINATION lib/fibio)
Loading

0 comments on commit 58bb7ce

Please sign in to comment.