1
1
set (CMAKE_LEGACY_CYGWIN_WIN32 0 )
2
2
cmake_minimum_required (VERSION 2.6 )
3
- project (casablanca )
3
+ project (cpprest )
4
4
5
5
enable_testing ()
6
6
7
7
set (WARNINGS )
8
8
set (ANDROID_STL_FLAGS )
9
9
10
+ option (WERROR "Threat Warnings as Errors" ON )
11
+ option (BUILD_TESTS "Build tests." ON )
12
+ option (CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF )
13
+
10
14
# Platform (not compiler) specific settings
11
15
if (IOS )
12
16
set (IOS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR} /../Build_iOS" )
@@ -25,7 +29,6 @@ if(IOS)
25
29
26
30
set (BUILD_SHARED_LIBS OFF )
27
31
set (BUILD_SAMPLES OFF )
28
- option (BUILD_TESTS "Build tests." ON )
29
32
elseif (ANDROID )
30
33
set (Boost_COMPILER "-clang" )
31
34
set (Boost_USE_STATIC_LIBS ON )
@@ -71,9 +74,8 @@ elseif(ANDROID)
71
74
72
75
option (BUILD_SHARED_LIBS "Build shared Libraries." OFF )
73
76
set (BUILD_SAMPLES OFF )
74
- option (BUILD_TESTS "Build tests." ON )
75
77
elseif (UNIX ) # This includes OSX
76
- find_package (Boost REQUIRED COMPONENTS random chrono system thread regex filesystem )
78
+ find_package (Boost 1.54 REQUIRED COMPONENTS random chrono system thread regex filesystem )
77
79
find_package (Threads REQUIRED )
78
80
if (APPLE AND NOT OPENSSL_ROOT_DIR )
79
81
# Prefer a homebrew version of OpenSSL over the one in /usr/lib
@@ -86,7 +88,6 @@ elseif(UNIX) # This includes OSX
86
88
find_package (OpenSSL 1.0.0 REQUIRED )
87
89
88
90
option (BUILD_SHARED_LIBS "Build shared Libraries." ON )
89
- option (BUILD_TESTS "Build tests." ON )
90
91
option (BUILD_SAMPLES "Build samples." ON )
91
92
option (CASA_INSTALL_HEADERS "Install header files." ON )
92
93
if (CASA_INSTALL_HEADERS )
@@ -99,9 +100,7 @@ elseif(UNIX) # This includes OSX
99
100
endif ()
100
101
elseif (WIN32 )
101
102
option (BUILD_SHARED_LIBS "Build shared Libraries." ON )
102
- option (BUILD_TESTS "Build tests." ON )
103
103
option (BUILD_SAMPLES "Build samples." ON )
104
- option (CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF )
105
104
option (Boost_USE_STATIC_LIBS ON )
106
105
107
106
add_definitions (-DUNICODE -D_UNICODE )
@@ -115,11 +114,31 @@ elseif(WIN32)
115
114
endif ()
116
115
add_definitions (${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -DWIN32 )
117
116
118
- if (CPPREST_EXCLUDE_WEBSOCKETS )
119
- add_definitions (-DCPPREST_EXCLUDE_WEBSOCKETS=1 )
120
- else ()
121
- find_package (Boost 1.55 REQUIRED COMPONENTS random system thread filesystem chrono atomic )
122
- find_package (OpenSSL 1.0 REQUIRED )
117
+ if (NOT CPPREST_EXCLUDE_WEBSOCKETS )
118
+ set (NUGET_PATH "${CMAKE_CURRENT_SOURCE_DIR} /../packages" )
119
+ set (PACKAGE_PATHS )
120
+ list (APPEND PACKAGE_PATHS "${NUGET_PATH} /boost.1.58.0.0/" )
121
+ list (APPEND PACKAGE_PATHS "${NUGET_PATH} /boost_system-vc140.1.58.0-vs140rc/" )
122
+ list (APPEND PACKAGE_PATHS "${NUGET_PATH} /boost_date_time-vc140.1.58.0-vs140rc/" )
123
+ list (APPEND PACKAGE_PATHS "${NUGET_PATH} /boost_regex-vc140.1.58.0-vs140rc/" )
124
+ list (APPEND PACKAGE_PATHS "${NUGET_PATH} /openssl.v140.windesktop.msvcstl.static.rt-dyn.x64.1.0.2.1/" )
125
+ list (APPEND PACKAGE_PATHS "${NUGET_PATH} /zlib.v140.windesktop.msvcstl.static.rt-dyn.1.2.8.8/" )
126
+
127
+ if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE )
128
+ find_library (Boost_SYSTEM_LIBRARY libboost_system-vc140-mt-gd-1_58.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/address-model-64/lib )
129
+ find_library (Boost_DATE_TIME_LIBRARY libboost_date_time-vc140-mt-gd-1_58.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/address-model-64/lib )
130
+ find_library (Boost_REGEX_LIBRARY libboost_regex-vc140-mt-gd-1_58.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/address-model-64/lib )
131
+ set (Boost_LIBRARIES ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY} )
132
+
133
+ find_library (OpenSSL_libeay_LIBRARY libeay32.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/v140/windesktop/msvcstl/static/rt-dyn/x64/debug )
134
+ find_library (OpenSSL_ssleay_LIBRARY ssleay32.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/v140/windesktop/msvcstl/static/rt-dyn/x64/debug )
135
+ find_library (ZLIB_LIBRARY zlibstaticd.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/v140/windesktop/msvcstl/static/rt-dyn/x64/debug )
136
+ set (OPENSSL_LIBRARIES ${OpenSSL_ssleay_LIBRARY} ${OpenSSL_libeay_LIBRARY} ${ZLIB_LIBRARY} )
137
+
138
+ set (OPENSSL_INCLUDE_DIR "${NUGET_PATH} /openssl.v140.windesktop.msvcstl.static.rt-dyn.x64.1.0.2.1/build/native/include" )
139
+ endif ()
140
+
141
+ set (Boost_INCLUDE_DIR "${NUGET_PATH} /boost.1.58.0.0/lib/native/include" )
123
142
endif ()
124
143
else ()
125
144
message (FATAL_ERROR "-- Unsupported Build Platform." )
@@ -158,11 +177,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
158
177
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
159
178
message ("-- Setting msvc options" )
160
179
set (WARNINGS )
180
+ set (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4264" )
181
+ add_compile_options (/bigobj )
182
+ if (WINDOWS_STORE OR WINDOWS_PHONE )
183
+ add_compile_options (/ZW )
184
+ endif ()
161
185
else ()
162
186
message ("-- Unknown compiler, success is doubtful." )
163
187
message ("CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID} " )
164
188
endif ()
165
189
190
+ if (CPPREST_EXCLUDE_WEBSOCKETS )
191
+ add_definitions (-DCPPREST_EXCLUDE_WEBSOCKETS=1 )
192
+ endif ()
193
+
166
194
# Reconfigure final output directory
167
195
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /Binaries )
168
196
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /Binaries )
@@ -188,16 +216,8 @@ else()
188
216
set (Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} /include )
189
217
endif ()
190
218
191
- set (Casablanca_LIBRARY ${LIB} cpprest )
192
- set (Casablanca_LIBRARIES ${Casablanca_LIBRARY}
193
- ${Boost_FILESYSTEM_LIBRARY}
194
- ${Boost_SYSTEM_LIBRARY}
195
- ${Boost_THREAD_LIBRARY}
196
- ${Boost_ATOMIC_LIBRARY}
197
- ${Boost_CHRONO_LIBRARY}
198
- ${Boost_RANDOM_LIBRARY}
199
- ${Boost_REGEX_LIBRARY}
200
- ${Boost_FRAMEWORK} )
219
+ set (Casablanca_LIBRARY cpprest )
220
+ set (Casablanca_LIBRARIES cpprest ${Boost_LIBRARIES} )
201
221
202
222
# Everything in the project needs access to the casablanca include directories
203
223
include_directories (${Casablanca_INCLUDE_DIRS} )
@@ -208,16 +228,16 @@ function(add_casablanca_test NAME SOURCES_VAR)
208
228
message ("-- Added test library ${NAME} " )
209
229
if (NOT TEST_LIBRARY_TARGET_TYPE STREQUAL "OBJECT" )
210
230
target_link_libraries (${NAME}
211
- ${LIB} httptest_utilities
212
- ${LIB} common_utilities
213
- ${LIB} unittestpp
231
+ httptest_utilities
232
+ common_utilities
233
+ unittestpp
214
234
${Casablanca_LIBRARIES}
215
235
${ANDROID_STL_FLAGS}
216
236
)
217
237
if (BUILD_SHARED_LIBS )
218
238
add_test (NAME ${NAME}
219
239
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
220
- COMMAND test_runner lib$ {NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
240
+ COMMAND test_runner $< TARGET_FILE_NAME: $ {NAME}>
221
241
)
222
242
endif ()
223
243
endif ()
0 commit comments