• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1cmake_minimum_required (VERSION 2.8.8)
2project (Simple-Web-Server)
3set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
4
5include_directories(.)
6
7find_package(Threads REQUIRED)
8
9set(BOOST_COMPONENTS system thread filesystem date_time)
10# Late 2017 TODO: remove the following checks and always use std::regex
11if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
12    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
13        set(BOOST_COMPONENTS ${BOOST_COMPONENTS} regex)
14        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST_REGEX")
15    endif()
16endif()
17find_package(Boost 1.53.0 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
18include_directories(SYSTEM ${Boost_INCLUDE_DIR})
19
20if(APPLE)
21    set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
22endif()
23
24add_executable(http_examples http_examples.cpp)
25target_link_libraries(http_examples ${Boost_LIBRARIES})
26target_link_libraries(http_examples ${CMAKE_THREAD_LIBS_INIT})
27
28#TODO: add requirement for version 1.0.1g (can it be done in one line?)
29find_package(OpenSSL)
30
31if(OPENSSL_FOUND)
32    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENSSL")
33    target_link_libraries(http_examples ${OPENSSL_LIBRARIES})
34    include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
35
36    add_executable(https_examples https_examples.cpp)
37    target_link_libraries(https_examples ${Boost_LIBRARIES})
38    target_link_libraries(https_examples ${OPENSSL_LIBRARIES})
39    target_link_libraries(https_examples ${CMAKE_THREAD_LIBS_INIT})
40endif()
41
42if(MSYS) #TODO: Is MSYS true when MSVC is true?
43    target_link_libraries(http_examples ws2_32 wsock32)
44    if(OPENSSL_FOUND)
45        target_link_libraries(https_examples ws2_32 wsock32)
46    endif()
47endif()
48
49enable_testing()
50add_subdirectory(tests)
51
52install(FILES server_http.hpp client_http.hpp server_https.hpp client_https.hpp DESTINATION include/simple-web-server)
53