1+ set (WEBSOCKETPP_PLATFORM_LIBS "" )
2+ set (WEBSOCKETPP_PLATFORM_TLS_LIBS "" )
3+ set (WEBSOCKETPP_BOOST_LIBS "" )
4+
5+ # VC9 and C++11 reasoning
6+ if (ENABLE_CPP11 AND MSVC AND MSVC90 )
7+ message ("* Detected Visual Studio 9 2008, disabling C++11 support." )
8+ set (ENABLE_CPP11 FALSE )
9+ endif ()
10+
11+ # Detect clang. Not officially reported by cmake.
12+ execute_process (COMMAND "${CMAKE_CXX_COMPILER} " "-v" ERROR_VARIABLE CXX_VER_STDERR)
13+ if ("${CXX_VER_STDERR} " MATCHES ".*clang.*" )
14+ set (CMAKE_COMPILER_IS_CLANGXX 1)
15+ endif ()
16+
17+ # C++11 defines
18+ if (ENABLE_CPP11)
19+ if (MSVC )
20+ add_definitions (-D_WEBSOCKETPP_CPP11_FUNCTIONAL_)
21+ add_definitions (-D_WEBSOCKETPP_CPP11_SYSTEM_ERROR_)
22+ add_definitions (-D_WEBSOCKETPP_CPP11_RANDOM_DEVICE_)
23+ add_definitions (-D_WEBSOCKETPP_CPP11_MEMORY_)
24+ else ()
25+ add_definitions (-D_WEBSOCKETPP_CPP11_STL_)
26+ endif ()
27+ endif ()
28+
29+ # Visual studio
30+ if (MSVC )
31+ set (WEBSOCKETPP_BOOST_LIBS system thread)
32+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL /Gy /GF /Ox /Ob2 /Ot /Oi /MP /arch:SSE2 /fp:fast" )
33+ set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG /INCREMENTAL:NO /OPT:REF /OPT:ICF" )
34+ add_definitions (/W3 /wd4996 /wd4995 /wd4355)
35+ add_definitions (-DUNICODE -D_UNICODE)
36+ add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
37+ add_definitions (-DNOMINMAX)
38+ endif ()
39+
40+ # g++
41+ if (CMAKE_COMPILER_IS_GNUCXX)
42+ set (WEBSOCKETPP_PLATFORM_LIBS pthread rt)
43+ set (WEBSOCKETPP_PLATFORM_TLS_LIBS ssl crypto)
44+ set (WEBSOCKETPP_BOOST_LIBS system thread)
45+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x" )
46+ if (NOT APPLE )
47+ add_definitions (-DNDEBUG -Wall -Wcast-align) # todo: should we use CMAKE_C_FLAGS for these?
48+ endif ()
49+
50+ # Try to detect version. Note: Not tested!
51+ execute_process (COMMAND ${CMAKE_CXX_COMPILER} "-dumpversion" OUTPUT_VARIABLE GCC_VERSION)
52+ if ("${GCC_VERSION} " STRGREATER "4.4.0" )
53+ message ("* C++11 support partially enabled due to GCC version ${GCC_VERSION} " )
54+ set (WEBSOCKETPP_BOOST_LIBS system thread)
55+ endif ()
56+ endif ()
57+
58+ # clang
59+ if (CMAKE_COMPILER_IS_CLANGXX)
60+ if (NOT APPLE )
61+ set (WEBSOCKETPP_PLATFORM_LIBS pthread rt)
62+ else ()
63+ set (WEBSOCKETPP_PLATFORM_LIBS pthread)
64+ endif ()
65+ set (WEBSOCKETPP_PLATFORM_TLS_LIBS ssl crypto)
66+ set (WEBSOCKETPP_BOOST_LIBS system thread)
67+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -stdlib=libc++" ) # todo: is libc++ really needed here?
68+ if (NOT APPLE )
69+ add_definitions (-DNDEBUG -Wall -Wno-padded) # todo: should we use CMAKE_C_FLAGS for these?
70+ endif ()
71+ endif ()
72+
73+ # OSX, can override above.
74+ if (APPLE )
75+ add_definitions (-DNDEBUG -Wall)
76+ endif ()
77+
78+ # Set BOOST_ROOT env variable or pass with cmake -DBOOST_ROOT=path.
79+ # BOOST_ROOT can also be defined by a previous run from cmake cache.
80+ if (NOT "$ENV{BOOST_ROOT_CPP11} " STREQUAL "" )
81+ # Scons documentation for BOOST_ROOT_CPP11:
82+ # "look for optional second boostroot compiled with clang's libc++ STL library
83+ # this prevents warnings/errors when linking code built with two different
84+ # incompatible STL libraries."
85+ file (TO_CMAKE_PATH "$ENV{BOOST_ROOT_CPP11} " BOOST_ROOT)
86+ set (BOOST_ROOT ${BOOST_ROOT} CACHE PATH "BOOST_ROOT dependency path" FORCE)
87+ endif ()
88+ if ("${BOOST_ROOT} " STREQUAL "" )
89+ file (TO_CMAKE_PATH "$ENV{BOOST_ROOT} " BOOST_ROOT)
90+ # Cache BOOST_ROOT for runs that do not define $ENV{BOOST_ROOT}.
91+ set (BOOST_ROOT ${BOOST_ROOT} CACHE PATH "BOOST_ROOT dependency path" FORCE)
92+ endif ()
93+
94+ if (MSVC )
95+ set (Boost_USE_MULTITHREADED TRUE )
96+ set (Boost_USE_STATIC_LIBS TRUE )
97+ else ()
98+ set (Boost_USE_MULTITHREADED FALSE )
99+ set (Boost_USE_STATIC_LIBS FALSE )
100+ endif ()
101+
102+ if (BOOST_STATIC)
103+ set (Boost_USE_STATIC_LIBS TRUE )
104+ endif ()
105+
106+ if (NOT Boost_USE_STATIC_LIBS)
107+ add_definitions (/DBOOST_TEST_DYN_LINK)
108+ endif ()
109+
110+ set (Boost_FIND_REQUIRED TRUE )
111+ set (Boost_FIND_QUIETLY TRUE )
112+ set (Boost_DEBUG FALSE )
113+ set (Boost_USE_MULTITHREADED TRUE )
114+ set (Boost_ADDITIONAL_VERSIONS "1.39.0" "1.40.0" "1.41.0" "1.42.0" "1.43.0" "1.44.0" "1.46.1" ) # todo: someone who knows better spesify these!
115+
116+ find_package (Boost 1.39.0 COMPONENTS "${WEBSOCKETPP_BOOST_LIBS} " )
117+
118+ if (Boost_FOUND)
119+ # Boost is a project wide global dependency.
120+ include_directories (${Boost_INCLUDE_DIRS} )
121+ link_directories (${Boost_LIBRARY_DIRS} )
122+
123+ # Pretty print status
124+ message (STATUS "-- Include Directories" )
125+ foreach (include_dir ${Boost_INCLUDE_DIRS} )
126+ message (STATUS " " ${include_dir} )
127+ endforeach ()
128+ message (STATUS "-- Library Directories" )
129+ foreach (library_dir ${Boost_LIBRARY_DIRS} )
130+ message (STATUS " " ${library_dir} )
131+ endforeach ()
132+ message (STATUS "-- Libraries" )
133+ foreach (boost_lib ${Boost_LIBRARIES} )
134+ message (STATUS " " ${boost_lib} )
135+ endforeach ()
136+ message ("" )
137+ else ()
138+ message (FATAL_ERROR "Failed to find required dependency: boost" )
139+ endif ()
140+
141+ find_package (OpenSSL)
142+ find_package (ZLIB)
0 commit comments