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
10
option (WERROR "Threat Warnings as Errors" ON )
11
+ option (BUILD_TESTS "Build tests." ON )
12
+ option (CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF )
11
13
12
14
# Platform (not compiler) specific settings
13
15
if (IOS)
@@ -27,7 +29,6 @@ if(IOS)
27
29
28
30
set (BUILD_SHARED_LIBS OFF )
29
31
set (BUILD_SAMPLES OFF )
30
- option (BUILD_TESTS "Build tests." ON )
31
32
elseif (ANDROID)
32
33
set (Boost_COMPILER "-clang" )
33
34
set (Boost_USE_STATIC_LIBS ON )
@@ -73,7 +74,6 @@ elseif(ANDROID)
73
74
74
75
option (BUILD_SHARED_LIBS "Build shared Libraries." OFF )
75
76
set (BUILD_SAMPLES OFF )
76
- option (BUILD_TESTS "Build tests." ON )
77
77
elseif (UNIX ) # This includes OSX
78
78
find_package (Boost 1.54 REQUIRED COMPONENTS random chrono system thread regex filesystem)
79
79
find_package (Threads REQUIRED)
@@ -88,7 +88,6 @@ elseif(UNIX) # This includes OSX
88
88
find_package (OpenSSL 1.0.0 REQUIRED)
89
89
90
90
option (BUILD_SHARED_LIBS "Build shared Libraries." ON )
91
- option (BUILD_TESTS "Build tests." ON )
92
91
option (BUILD_SAMPLES "Build samples." ON )
93
92
option (CASA_INSTALL_HEADERS "Install header files." ON )
94
93
if (CASA_INSTALL_HEADERS)
@@ -101,9 +100,7 @@ elseif(UNIX) # This includes OSX
101
100
endif ()
102
101
elseif (WIN32 )
103
102
option (BUILD_SHARED_LIBS "Build shared Libraries." ON )
104
- option (BUILD_TESTS "Build tests." ON )
105
103
option (BUILD_SAMPLES "Build samples." ON )
106
- option (CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF )
107
104
option (Boost_USE_STATIC_LIBS ON )
108
105
109
106
add_definitions (-DUNICODE -D_UNICODE)
@@ -117,11 +114,31 @@ elseif(WIN32)
117
114
endif ()
118
115
add_definitions (${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -DWIN32)
119
116
120
- if (CPPREST_EXCLUDE_WEBSOCKETS)
121
- add_definitions (-DCPPREST_EXCLUDE_WEBSOCKETS=1)
122
- else ()
123
- find_package (Boost 1.55 REQUIRED COMPONENTS random system thread filesystem chrono atomic)
124
- 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" )
125
142
endif ()
126
143
else ()
127
144
message (FATAL_ERROR "-- Unsupported Build Platform." )
@@ -160,12 +177,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
160
177
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
161
178
message ("-- Setting msvc options" )
162
179
set (WARNINGS)
180
+ set (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4264" )
163
181
add_compile_options (/bigobj)
182
+ if (WINDOWS_STORE OR WINDOWS_PHONE)
183
+ add_compile_options (/ZW)
184
+ endif ()
164
185
else ()
165
186
message ("-- Unknown compiler, success is doubtful." )
166
187
message ("CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID} " )
167
188
endif ()
168
189
190
+ if (CPPREST_EXCLUDE_WEBSOCKETS)
191
+ add_definitions (-DCPPREST_EXCLUDE_WEBSOCKETS=1)
192
+ endif ()
193
+
169
194
# Reconfigure final output directory
170
195
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /Binaries)
171
196
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /Binaries)
@@ -191,9 +216,8 @@ else()
191
216
set (Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} /include )
192
217
endif ()
193
218
194
- set (Casablanca_LIBRARY ${LIB} cpprest)
195
- set (Casablanca_LIBRARIES ${Casablanca_LIBRARY}
196
- ${Boost_LIBRARIES} )
219
+ set (Casablanca_LIBRARY cpprest)
220
+ set (Casablanca_LIBRARIES cpprest ${Boost_LIBRARIES} )
197
221
198
222
# Everything in the project needs access to the casablanca include directories
199
223
include_directories (${Casablanca_INCLUDE_DIRS} )
@@ -204,16 +228,16 @@ function(add_casablanca_test NAME SOURCES_VAR)
204
228
message ("-- Added test library ${NAME} " )
205
229
if (NOT TEST_LIBRARY_TARGET_TYPE STREQUAL "OBJECT" )
206
230
target_link_libraries (${NAME}
207
- ${LIB} httptest_utilities
208
- ${LIB} common_utilities
209
- ${LIB} unittestpp
231
+ httptest_utilities
232
+ common_utilities
233
+ unittestpp
210
234
${Casablanca_LIBRARIES}
211
235
${ANDROID_STL_FLAGS}
212
236
)
213
237
if (BUILD_SHARED_LIBS )
214
238
add_test (NAME ${NAME}
215
239
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
216
- COMMAND test_runner lib $ {NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
240
+ COMMAND test_runner $<TARGET_FILE_NAME: $ {NAME}>
217
241
)
218
242
endif ()
219
243
endif ()
0 commit comments