Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

168 lines (146 sloc) 6.293 kb
# Copyright (c) Dean Michael Berris 2010.
# Copyright (c) Google, Inc. 2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 2.8)
project(CPP-NETLIB)
option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF )
option( CPP-NETLIB_BUILD_SINGLE_LIB "Build cpp-netlib into a single library" OFF )
option( CPP-NETLIB_BUILD_TESTS "Build the unit tests." ON )
option( CPP-NETLIB_BUILD_EXAMPLES "Build the examples using cpp-netlib." ON )
option( CPP-NETLIB_ALWAYS_LOGGING "Allow cpp-netlib to log debug messages even in non-debug mode." OFF )
option( CPP-NETLIB_DISABLE_LOGGING "Disable logging definitely, no logging code will be generated or compiled." OFF )
option( CPP-NETLIB_DISABLE_LIBCXX "Disable using libc++ when compiling with clang." OFF )
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package( ICU )
if(CPP-NETLIB_BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
set(Boost_USE_STATIC_LIBS OFF)
set(CPP-NETLIB_BUILD_SHARED_LIBS ON)
set(BUILD_SHARED_LIBS ON)
else()
set(Boost_USE_STATIC_LIBS ON)
set(CPP-NETLIB_BUILD_SHARED_LIBS OFF)
set(BUILD_SHARED_LIBS OFF)
endif()
set(Boost_USE_MULTITHREADED ON)
set(Boost_COMPONENTS system regex date_time filesystem program_options )
find_package( Boost 1.51 REQUIRED ${Boost_COMPONENTS} )
find_package( OpenSSL )
find_package( Threads )
set(CMAKE_VERBOSE_MAKEFILE true)
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DNETWORK_DEBUG)
endif()
if (OPENSSL_FOUND)
add_definitions(-DNETWORK_ENABLE_HTTPS)
endif()
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
if (HAVE_STD11)
list(APPEND CMAKE_CXX_FLAGS "-std=c++11 -Wall")
else()
message(FATAL_ERROR "No advanced standard C++ support (-std=c++11 not defined).")
endif()
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAVE_STD11)
if (HAVE_STD11)
if (CPP-NETLIB_DISABLE_LIBCXX)
list(APPEND CMAKE_CXX_FLAGS "-std=c++11 -Wall")
list(APPEND CMAKE_CXX_LINK_FLAGS "-std=c++11")
else()
list(APPEND CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall")
list(APPEND CMAKE_CXX_LINK_FLAGS "-std=c++11 -stdlib=libc++")
endif()
else()
message(FATAL_ERROR "No C++11 support for Clang version. Please upgrade Clang to a version supporting C++11.")
endif()
add_definitions(
-DASIO_HAS_MOVE -DASIO_HAS_VARIADIC_TEMPLATES -DASIO_HAS_STD_SYSTEM_ERROR
-DASIO_ERROR_CATEGORY_NOEXCEPT=noexcept -DASIO_HAS_STD_ARRAY
-DASIO_HAS_STD_SHARED_PTR -DASIO_HAS_STD_ATOMIC -DASIO_HAS_STD_CHRONO
-DASIO_HAS_STD_ADDRESSOFF -DASIO_HAS_STD_FUNCTION -DASIO_HAS_STD_TYPE_TRAITS)
endif()
message("C++ Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
message("C++ Flags: ${CMAKE_CXX_FLAGS} link flags: ${CMAKE_CXX_LINK_FLAGS}")
if (Boost_FOUND)
if (MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif(MSVC)
if (WIN32)
add_definitions(-D_WIN32_WINNT=0x0501)
endif(WIN32)
include_directories(${Boost_INCLUDE_DIRS})
endif(Boost_FOUND)
message(STATUS "CPP-NETLIB options selected:")
message(STATUS " CPP-NETLIB_BUILD_SHARED_LIBS: ${CPP-NETLIB_BUILD_SHARED_LIBS}\t(Build cpp-netlib as shared libraries: OFF, ON)")
message(STATUS " CPP-NETLIB_BUILD_SINGLE_LIB: ${CPP-NETLIB_BUILD_SINGLE_LIB}\t(Build cpp-netlib into a single library: OFF, ON)")
message(STATUS " CPP-NETLIB_BUILD_TESTS: ${CPP-NETLIB_BUILD_TESTS}\t(Build the unit tests: ON, OFF)")
message(STATUS " CPP-NETLIB_BUILD_EXAMPLES: ${CPP-NETLIB_BUILD_EXAMPLES}\t(Build the examples using cpp-netlib: ON, OFF)")
message(STATUS " CPP-NETLIB_ALWAYS_LOGGING: ${CPP-NETLIB_ALWAYS_LOGGING}\t(Allow cpp-netlib to log debug messages even in non-debug mode: ON, OFF)")
message(STATUS " CPP-NETLIB_DISABLE_LOGGING: ${CPP-NETLIB_DISABLE_LOGGING}\t(Disable logging definitely, no logging code will be generated or compiled: ON, OFF)")
message(STATUS " CPP-NETLIB_DISABLE_LIBCXX: ${CPP-NETLIB_DISABLE_LIBCXX}\t(Disable using libc++ when building with clang: ON, OFF)")
message(STATUS "CMake build options selected:")
############################################################################
#
# The code following this point is for the new directory structure
#
if(CPP-NETLIB_BUILD_TESTS)
enable_testing()
if(MSVC11)
add_definitions(-D_VARIADIC_MAX=10)
endif(MSVC11)
if(MSVC)
set(gtest_force_shared_crt ON CACHE BOOL "Override gtest option.")
endif(MSVC)
# gmock automatically searches for gtest
add_subdirectory(deps/gmock)
set(GTEST_ROOT ${CPP-NETLIB_SOURCE_DIR}/deps/gtest)
set(GTEST_FOUND ON)
set(GTEST_INCLUDE_DIRS ${GTEST_ROOT}/include)
set(GTEST_LIBRARIES gtest)
set(GTEST_MAIN_LIBRARIES gtest_main)
set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
set(GMOCK_ROOT ${CPP-NETLIB_SOURCE_DIR}/deps/gmock)
set(GMOCK_FOUND ON)
set(GMOCK_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} {${GMOCK_DIR}/include)
set(GMOCK_LIBRARIES {$GTEST_LIBRARIES} gmock)
set(GMOCK_MAIN_LIBRARIES gmock_main)
set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARIES} ${GMOCK_MAIN_LIBRARIES})
endif()
if(CPP-NETLIB_BUILD_SINGLE_LIB)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/concurrency/src
${CMAKE_CURRENT_SOURCE_DIR}/http/src
${CMAKE_CURRENT_SOURCE_DIR}/logging/src
${CMAKE_CURRENT_SOURCE_DIR}/message/src
${CMAKE_CURRENT_SOURCE_DIR}/uri/src
)
endif()
add_subdirectory(uri)
add_subdirectory(message)
add_subdirectory(logging)
add_subdirectory(concurrency)
add_subdirectory(http)
#add_subdirectory(mime)
if(CPP-NETLIB_BUILD_EXAMPLES)
add_subdirectory(contrib/http_examples)
endif()
if(CPP-NETLIB_BUILD_SINGLE_LIB)
add_library(cppnetlib
${Uri_SRCS}
${CPP-NETLIB_MESSAGE_SRCS}
${CPP-NETLIB_MESSAGE_DIRECTIVES_SRCS}
${CPP-NETLIB_MESSAGE_WRAPPERS_SRCS}
${CPP-NETLIB_LOGGING_SRCS}
${CPP-NETLIB_HTTP_CLIENT_SRCS}
${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS}
${CPP-NETLIB_HTTP_MESSAGE_SRCS}
${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS}
${CPP-NETLIB_CONSTANTS_SRCS}
${CPP-NETLIB_CONCURRENCY_SRCS}
)
target_link_libraries(cppnetlib ${Boost_LIBRARIES})
endif()
Jump to Line
Something went wrong with that request. Please try again.