Skip to content

Commit 5abe0cb

Browse files
committed
Merge branch 'improve-buildsystem' into development
Conflicts: Release/CMakeLists.txt Release/src/CMakeLists.txt
2 parents 54d7fcd + 834491e commit 5abe0cb

File tree

21 files changed

+256
-153
lines changed

21 files changed

+256
-153
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ Intermediate/
6363
**/packages/*
6464
# except build/, which is used as an MSBuild target.
6565
!**/packages/build/
66-
66+
.vs/
67+
# Ignore cmake building directories
68+
build.*/

Release/CMakeLists.txt

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
22
cmake_minimum_required(VERSION 2.6)
3-
project(casablanca)
3+
project(cpprest)
44

55
enable_testing()
66

77
set(WARNINGS)
88
set(ANDROID_STL_FLAGS)
99

1010
option(WERROR "Threat Warnings as Errors" ON)
11+
option(BUILD_TESTS "Build tests." ON)
12+
option(CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF)
1113

1214
# Platform (not compiler) specific settings
1315
if(IOS)
@@ -27,7 +29,6 @@ if(IOS)
2729

2830
set(BUILD_SHARED_LIBS OFF)
2931
set(BUILD_SAMPLES OFF)
30-
option(BUILD_TESTS "Build tests." ON)
3132
elseif(ANDROID)
3233
set(Boost_COMPILER "-clang")
3334
set(Boost_USE_STATIC_LIBS ON)
@@ -73,7 +74,6 @@ elseif(ANDROID)
7374

7475
option(BUILD_SHARED_LIBS "Build shared Libraries." OFF)
7576
set(BUILD_SAMPLES OFF)
76-
option(BUILD_TESTS "Build tests." ON)
7777
elseif(UNIX) # This includes OSX
7878
find_package(Boost 1.54 REQUIRED COMPONENTS random chrono system thread regex filesystem)
7979
find_package(Threads REQUIRED)
@@ -88,7 +88,6 @@ elseif(UNIX) # This includes OSX
8888
find_package(OpenSSL 1.0.0 REQUIRED)
8989

9090
option(BUILD_SHARED_LIBS "Build shared Libraries." ON)
91-
option(BUILD_TESTS "Build tests." ON)
9291
option(BUILD_SAMPLES "Build samples." ON)
9392
option(CASA_INSTALL_HEADERS "Install header files." ON)
9493
if(CASA_INSTALL_HEADERS)
@@ -101,9 +100,7 @@ elseif(UNIX) # This includes OSX
101100
endif()
102101
elseif(WIN32)
103102
option(BUILD_SHARED_LIBS "Build shared Libraries." ON)
104-
option(BUILD_TESTS "Build tests." ON)
105103
option(BUILD_SAMPLES "Build samples." ON)
106-
option(CPPREST_EXCLUDE_WEBSOCKETS "Exclude websockets functionality." OFF)
107104
option(Boost_USE_STATIC_LIBS ON)
108105

109106
add_definitions(-DUNICODE -D_UNICODE)
@@ -117,11 +114,31 @@ elseif(WIN32)
117114
endif()
118115
add_definitions(${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -DWIN32)
119116

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")
125142
endif()
126143
else()
127144
message(FATAL_ERROR "-- Unsupported Build Platform.")
@@ -160,12 +177,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
160177
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
161178
message("-- Setting msvc options")
162179
set(WARNINGS)
180+
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4264")
163181
add_compile_options(/bigobj)
182+
if (WINDOWS_STORE OR WINDOWS_PHONE)
183+
add_compile_options(/ZW)
184+
endif()
164185
else()
165186
message("-- Unknown compiler, success is doubtful.")
166187
message("CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}")
167188
endif()
168189

190+
if (CPPREST_EXCLUDE_WEBSOCKETS)
191+
add_definitions(-DCPPREST_EXCLUDE_WEBSOCKETS=1)
192+
endif()
193+
169194
# Reconfigure final output directory
170195
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
171196
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
@@ -191,9 +216,8 @@ else()
191216
set(Casablanca_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
192217
endif()
193218

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})
197221

198222
# Everything in the project needs access to the casablanca include directories
199223
include_directories(${Casablanca_INCLUDE_DIRS})
@@ -204,16 +228,16 @@ function(add_casablanca_test NAME SOURCES_VAR)
204228
message("-- Added test library ${NAME}")
205229
if (NOT TEST_LIBRARY_TARGET_TYPE STREQUAL "OBJECT")
206230
target_link_libraries(${NAME}
207-
${LIB}httptest_utilities
208-
${LIB}common_utilities
209-
${LIB}unittestpp
231+
httptest_utilities
232+
common_utilities
233+
unittestpp
210234
${Casablanca_LIBRARIES}
211235
${ANDROID_STL_FLAGS}
212236
)
213237
if (BUILD_SHARED_LIBS)
214238
add_test(NAME ${NAME}
215239
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
216-
COMMAND test_runner lib${NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
240+
COMMAND test_runner $<TARGET_FILE_NAME:${NAME}>
217241
)
218242
endif()
219243
endif()
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
add_executable(BingRequest bingrequest.cpp)
2-
target_link_libraries(BingRequest ${Casablanca_LIBRARIES})
1+
if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE)
2+
add_executable(BingRequest bingrequest.cpp)
3+
target_link_libraries(BingRequest ${Casablanca_LIBRARIES})
4+
endif()
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
add_subdirectory(BlackJack_Server)
2-
add_subdirectory(BlackJack_Client)
1+
if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE)
2+
add_subdirectory(BlackJack_Server)
3+
add_subdirectory(BlackJack_Client)
4+
else()
5+
# TODO: add BlackJack_UIClient
6+
endif()
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
2-
add_executable(oauth1client
3-
Oauth1Client.cpp
4-
stdafx.cpp
5-
)
6-
7-
target_link_libraries(oauth1client ${Casablanca_LIBRARIES})
1+
if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE)
2+
add_executable(oauth1client
3+
Oauth1Client.cpp
4+
stdafx.cpp
5+
)
6+
7+
target_link_libraries(oauth1client ${Casablanca_LIBRARIES})
8+
endif()
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE)
2+
add_executable(oauth2client
3+
Oauth2Client.cpp
4+
stdafx.cpp
5+
)
16

2-
add_executable(oauth2client
3-
Oauth2Client.cpp
4-
stdafx.cpp
5-
)
6-
7-
target_link_libraries(oauth2client ${Casablanca_LIBRARIES})
7+
target_link_libraries(oauth2client ${Casablanca_LIBRARIES})
8+
endif()
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
add_executable(SearchFile searchfile.cpp)
2-
target_link_libraries(SearchFile ${Casablanca_LIBRARIES})
1+
if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE)
2+
add_executable(SearchFile searchfile.cpp)
3+
target_link_libraries(SearchFile ${Casablanca_LIBRARIES})
4+
endif()

Release/src/CMakeLists.txt

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,21 @@ if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
33
include_directories(${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
44
endif()
55

6+
add_definitions(${WARNINGS})
7+
8+
file(GLOB SOURCES_CPPREST "../include/cpprest/*.h")
9+
file(GLOB SOURCES_PPLX "../include/pplx/*.h")
10+
file(GLOB SOURCES_DETAILS "../include/cpprest/details/*.h")
11+
source_group("Header Files\\cpprest" FILES ${SOURCES_CPPREST})
12+
source_group("Header Files\\pplx" FILES ${SOURCES_PPLX})
13+
source_group("Header Files\\cpprest\\details" FILES ${SOURCES_DETAILS})
614
set(SOURCES_COMMON
15+
${SOURCES_CPPREST}
16+
${SOURCES_PPLX}
17+
${SOURCES_DETAILS}
718
http/client/http_client.cpp
819
http/client/http_client_msg.cpp
20+
http/client/http_client_impl.h
921
http/client/x509_cert_utilities.cpp
1022
http/common/http_helpers.cpp
1123
http/common/http_msg.cpp
@@ -26,7 +38,6 @@ set(SOURCES_COMMON
2638
utilities/web_utilities.cpp
2739
websockets/client/ws_msg.cpp
2840
websockets/client/ws_client.cpp
29-
websockets/client/ws_client_wspp.cpp
3041
)
3142

3243
# THE ORDER OF FILES IS VERY /VERY/ IMPORTANT
@@ -38,6 +49,9 @@ if(UNIX)
3849
http/client/http_client_asio.cpp
3950
http/listener/http_server_asio.cpp
4051
)
52+
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
53+
list(APPEND SOURCES websockets/client/ws_client_wspp.cpp)
54+
endif()
4155
if(APPLE)
4256
list(APPEND SOURCES
4357
pplx/pplxapple.cpp
@@ -54,44 +68,61 @@ if(UNIX)
5468
endif()
5569

5670
if(WERROR)
57-
set(WARNINGS "${WARNINGS} -Werror")
71+
add_compile_options(-Werror)
5872
endif()
59-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS} -pedantic")
73+
add_compile_options(-pedantic)
6074
elseif(WIN32)
61-
set(SOURCES
62-
${SOURCES_COMMON}
63-
http/client/http_client_winhttp.cpp
64-
http/listener/http_server_httpsys.cpp
75+
set(SOURCES ${SOURCES_COMMON}
6576
pplx/pplxwin.cpp
66-
streams/fileio_win32.cpp
67-
pch/stdafx.cpp
6877
)
69-
set(EXTRALINKS
70-
bcrypt.lib
71-
crypt32.lib
72-
httpapi.lib
73-
Winhttp.lib
74-
)
75-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNINGS}")
76-
if (${CMAKE_GENERATOR} MATCHES "Visual Studio .*")
77-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Yustdafx.h /Zm200")
78-
set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
78+
if (WINDOWS_PHONE OR WINDOWS_STORE)
79+
list(APPEND SOURCES
80+
http/client/http_client_winrt.cpp
81+
streams/fileio_winrt.cpp
82+
websockets/client/ws_client_winrt.cpp
83+
)
84+
else()
85+
list(APPEND SOURCES
86+
http/client/http_client_winhttp.cpp
87+
http/listener/http_server_httpsys.cpp
88+
streams/fileio_win32.cpp
89+
)
90+
if (NOT CPPREST_EXCLUDE_WEBSOCKETS)
91+
list(APPEND SOURCES websockets/client/ws_client_wspp.cpp)
92+
endif()
93+
set(EXTRALINKS
94+
bcrypt.lib
95+
crypt32.lib
96+
httpapi.lib
97+
Winhttp.lib
98+
)
7999
endif()
100+
add_compile_options(/Yustdafx.h /Zm200)
101+
set_source_files_properties(pch/stdafx.cpp PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
102+
103+
if (NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio .*")
104+
set_property(SOURCE pch/stdafx.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch")
105+
set_property(SOURCE ${SOURCES} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/stdafx.pch")
106+
endif()
107+
108+
list(APPEND SOURCES pch/stdafx.cpp pch/stdafx.h)
80109

81110
if (BUILD_SHARED_LIBS)
82111
add_definitions(-D_ASYNCRT_EXPORT -D_PPLX_EXPORT -D_USRDLL)
83112
endif()
84113
endif()
85114

86-
add_library(${Casablanca_LIBRARY} ${SOURCES})
115+
add_library(cpprest ${SOURCES})
87116

88-
target_link_libraries(${Casablanca_LIBRARY}
117+
target_link_libraries(cpprest
89118
${CMAKE_THREAD_LIBS_INIT}
90119
${Boost_SYSTEM_LIBRARY}
91120
${Boost_THREAD_LIBRARY}
92121
${Boost_ATOMIC_LIBRARY}
93122
${Boost_CHRONO_LIBRARY}
94123
${Boost_RANDOM_LIBRARY}
124+
${Boost_REGEX_LIBRARY}
125+
${Boost_DATE_TIME_LIBRARY}
95126
${EXTRALINKS}
96127
${Boost_FRAMEWORK}
97128
${OPENSSL_LIBRARIES}
@@ -105,17 +136,17 @@ set (CPPREST_VERSION_MINOR 8)
105136
set (CPPREST_VERSION_REVISION 0)
106137

107138
if(WIN32)
108-
set_target_properties(${Casablanca_LIBRARY} PROPERTIES
109-
OUTPUT_NAME "${Casablanca_LIBRARY}_${CPPREST_VERSION_MAJOR}_${CPPREST_VERSION_MINOR}")
139+
set_target_properties(cpprest PROPERTIES
140+
OUTPUT_NAME "cpprest_${CPPREST_VERSION_MAJOR}_${CPPREST_VERSION_MINOR}")
110141
elseif(ANDROID)
111142
# Do not use SOVERSION on android. It is completely unsupported (and causes problems).
112143
# Perhaps revisit in the future? (NDK r9d, 8/7/14)
113144
else()
114-
set_target_properties(${Casablanca_LIBRARY} PROPERTIES
145+
set_target_properties(cpprest PROPERTIES
115146
SOVERSION ${CPPREST_VERSION_MAJOR}.${CPPREST_VERSION_MINOR})
116147

117148
install(
118-
TARGETS ${Casablanca_LIBRARY}
149+
TARGETS cpprest
119150
LIBRARY DESTINATION lib
120151
ARCHIVE DESTINATION lib
121152
)

Release/src/build/vs14.android/casablanca140.android.vcxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@
6060
<ImportGroup Label="PropertySheets" />
6161
<PropertyGroup Label="UserMacros" />
6262
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
63+
<UseMultiToolTask>true</UseMultiToolTask>
6364
</PropertyGroup>
6465
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
66+
<UseMultiToolTask>true</UseMultiToolTask>
6567
</PropertyGroup>
6668
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
6769
<ClCompile>
@@ -113,6 +115,12 @@
113115
<PropertyGroup>
114116
<TargetName>$(CppRestBaseFileName)140$(DebugFileSuffix)_android_$(CppRestSDKVersionFileSuffix)</TargetName>
115117
</PropertyGroup>
118+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
119+
<UseMultiToolTask>true</UseMultiToolTask>
120+
</PropertyGroup>
121+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
122+
<UseMultiToolTask>true</UseMultiToolTask>
123+
</PropertyGroup>
116124
<Import Project="..\common.vcxitems" Label="Shared" Condition="Exists('..\common.vcxitems')" />
117125
<Import Project="..\android.vcxitems" Label="Shared" Condition="Exists('..\android.vcxitems')" />
118126
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

0 commit comments

Comments
 (0)