Skip to content

Commit 8adef3d

Browse files
committed
IDES2-3488 hunterisation of 2.10.16 (#4)
* IDES2-3488 Re-hunterise latest upstream version Update to use hunter_add_package etc appropriately. * IDES2-3488 Minor fixes to previous Fix comment and add missing HunterGate * IDES2-3488 Add HunterGate call at top level Seems the top-level project needs a HunterGate after all. * IDES2-3488 Minor fixes so builds on Linux * IDES2-3488 Use PROJECT_NAME in installer Use PROJECT_NAME instead of hardwired cpprestsdk in installer, so should now be casablanca for us. * IDES2-3488 Further changes to allow project name override Further fixes so if we call it casablanca then files are installed at the correct place. * IDES2-3488 Default back to cpprestsdk Change the project name back to standard but allow override * IDES2-3488 Minor change to previous * IDES2-3488 Remove carriage returns from changed file * IDES2-3488 Fix scenario when the project_name is not supplied * IDES2-3488 Correct websocketpp version trace output Mixed-case variable is being set (cherry picked from commit e86c368)
1 parent 411a109 commit 8adef3d

9 files changed

+343
-22
lines changed

CMakeLists.txt

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
cmake_minimum_required(VERSION 3.9)
2-
project(cpprestsdk-root NONE)
3-
enable_testing()
4-
add_subdirectory(Release)
1+
cmake_minimum_required(VERSION 3.9)
2+
3+
include("Release/cmake/HunterGate.cmake")
4+
HunterGate(
5+
URL "http://192.168.2.27/packages/hunter/hunter-project-v1.0.60.tar.gz"
6+
SHA1 "e1a3b70805d481652b53737e4920b4dd712ad067"
7+
)
8+
9+
10+
project(cpprestsdk-root NONE)
11+
enable_testing()
12+
add_subdirectory(Release)

Release/CMakeLists.txt

+23-10
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,51 @@ cmake_minimum_required(VERSION 3.9)
33
if(POLICY CMP0042)
44
cmake_policy(SET CMP0042 NEW) # use MACOSX_RPATH
55
endif()
6-
if(UNIX)
7-
project(cpprestsdk C CXX)
8-
else()
9-
project(cpprestsdk CXX)
10-
endif()
116

127
set(CPPREST_VERSION_MAJOR 2)
138
set(CPPREST_VERSION_MINOR 10)
149
set(CPPREST_VERSION_REVISION 19)
1510

11+
# Note idscan version - allow override to still use "casablanca" instead of "cpprestsdk" as upstream has changed to
12+
if("${CPPREST_PROJECT}" STREQUAL "")
13+
set(CPPREST_PROJECT cpprestsdk)
14+
endif()
15+
set(CPPREST_VERSION ${CPPREST_VERSION_MAJOR}.${CPPREST_VERSION_MINOR}.${CPPREST_VERSION_REVISION})
16+
17+
include("cmake/HunterGate.cmake")
18+
HunterGate(
19+
URL "http://192.168.2.27/packages/hunter/hunter-project-v1.0.60.tar.gz"
20+
SHA1 "e1a3b70805d481652b53737e4920b4dd712ad067"
21+
)
22+
23+
if(UNIX)
24+
project(${CPPREST_PROJECT} LANGUAGES C CXX VERSION ${CPPREST_VERSION})
25+
else()
26+
project(${CPPREST_PROJECT} LANGUAGES CXX VERSION ${CPPREST_VERSION})
27+
endif()
28+
1629
enable_testing()
1730

1831
set(WERROR ON CACHE BOOL "Treat Warnings as Errors.")
1932
set(CPPREST_EXCLUDE_WEBSOCKETS OFF CACHE BOOL "Exclude websockets functionality.")
2033
set(CPPREST_EXCLUDE_COMPRESSION OFF CACHE BOOL "Exclude compression functionality.")
2134
set(CPPREST_EXCLUDE_BROTLI ON CACHE BOOL "Exclude Brotli compression functionality.")
22-
set(CPPREST_EXPORT_DIR cmake/cpprestsdk CACHE STRING "Directory to install CMake config files.")
35+
set(CPPREST_EXPORT_DIR cmake/${PROJECT_NAME} CACHE STRING "Directory to install CMake config files.")
2336
set(CPPREST_INSTALL_HEADERS ON CACHE BOOL "Install header files.")
2437
set(CPPREST_INSTALL ON CACHE BOOL "Add install commands.")
2538

2639
if(IOS OR ANDROID)
2740
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries")
2841
else()
29-
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
42+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries")
3043
endif()
3144

3245
if(IOS OR ANDROID OR WINDOWS_STORE OR WINDOWS_PHONE)
3346
set(BUILD_TESTS OFF CACHE BOOL "Build tests.")
3447
set(BUILD_SAMPLES OFF CACHE BOOL "Build sample applications.")
3548
else()
36-
set(BUILD_TESTS ON CACHE BOOL "Build tests.")
37-
set(BUILD_SAMPLES ON CACHE BOOL "Build sample applications.")
49+
set(BUILD_TESTS OFF CACHE BOOL "Build tests.")
50+
set(BUILD_SAMPLES OFF CACHE BOOL "Build sample applications.")
3851
endif()
3952

4053
if(WIN32)
@@ -56,7 +69,7 @@ endif()
5669
if(ANDROID)
5770
set(Boost_USE_STATIC_LIBS ON CACHE BOOL "Link against boost statically.")
5871
else()
59-
set(Boost_USE_STATIC_LIBS OFF CACHE BOOL "Link against boost statically.")
72+
set(Boost_USE_STATIC_LIBS ON CACHE BOOL "Link against boost statically.")
6073
endif()
6174

6275
include(cmake/cpprest_find_boost.cmake)

Release/cmake/HunterGate.cmake

+261
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
# Copyright (c) 2013-2015, Ruslan Baratov
2+
# All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# * Redistributions of source code must retain the above copyright notice, this
8+
# list of conditions and the following disclaimer.
9+
#
10+
# * Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
25+
# This is a gate file to Hunter package manager.
26+
# Include this file using `include` command and add package you need, example:
27+
#
28+
# cmake_minimum_required(VERSION 3.0)
29+
#
30+
# include("cmake/HunterGate.cmake")
31+
# HunterGate(
32+
# URL "https://github.com/path/to/hunter/archive.tar.gz"
33+
# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d"
34+
# )
35+
#
36+
# project(MyProject)
37+
#
38+
# hunter_add_package(Foo)
39+
# hunter_add_package(Boo COMPONENTS Bar Baz)
40+
#
41+
# Projects:
42+
# * https://github.com/hunter-packages/gate/
43+
# * https://github.com/ruslo/hunter
44+
45+
cmake_minimum_required(VERSION 3.0) # Minimum for Hunter
46+
include(CMakeParseArguments) # cmake_parse_arguments
47+
48+
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
49+
option(HUNTER_STATUS_PRINT "Print working status" ON)
50+
option(HUNTER_STATUS_DEBUG "Print a lot info" OFF)
51+
52+
set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki")
53+
54+
function(hunter_gate_wiki wiki_page)
55+
message("------------------------------ WIKI -------------------------------")
56+
message(" ${HUNTER_WIKI}/${wiki_page}")
57+
message("-------------------------------------------------------------------")
58+
message("")
59+
message(FATAL_ERROR "")
60+
endfunction()
61+
62+
function(hunter_gate_internal_error)
63+
message("")
64+
foreach(print_message ${ARGV})
65+
message("[hunter ** INTERNAL **] ${print_message}")
66+
endforeach()
67+
message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
68+
message("")
69+
hunter_gate_wiki("error.internal")
70+
endfunction()
71+
72+
function(hunter_gate_fatal_error)
73+
cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}")
74+
if(NOT hunter_WIKI)
75+
hunter_gate_internal_error("Expected wiki")
76+
endif()
77+
message("")
78+
foreach(x ${hunter_UNPARSED_ARGUMENTS})
79+
message("[hunter ** FATAL ERROR **] ${x}")
80+
endforeach()
81+
message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
82+
message("")
83+
hunter_gate_wiki("${hunter_WIKI}")
84+
endfunction()
85+
86+
function(hunter_gate_user_error)
87+
hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data")
88+
endfunction()
89+
90+
function(hunter_gate_self root version sha1 result)
91+
string(COMPARE EQUAL "${root}" "" is_bad)
92+
if(is_bad)
93+
hunter_gate_internal_error("root is empty")
94+
endif()
95+
96+
string(COMPARE EQUAL "${version}" "" is_bad)
97+
if(is_bad)
98+
hunter_gate_internal_error("version is empty")
99+
endif()
100+
101+
string(COMPARE EQUAL "${sha1}" "" is_bad)
102+
if(is_bad)
103+
hunter_gate_internal_error("sha1 is empty")
104+
endif()
105+
106+
string(SUBSTRING "${sha1}" 0 7 archive_id)
107+
108+
if(EXISTS "${root}/cmake/Hunter")
109+
set(hunter_self "${root}")
110+
else()
111+
set(
112+
hunter_self
113+
"${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked"
114+
)
115+
endif()
116+
117+
set("${result}" "${hunter_self}" PARENT_SCOPE)
118+
endfunction()
119+
120+
# Set HUNTER_GATE_ROOT cmake variable to suitable value.
121+
function(hunter_gate_detect_root)
122+
# Check CMake variable
123+
if(HUNTER_ROOT)
124+
set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE)
125+
return()
126+
endif()
127+
128+
# Check environment variable
129+
string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty)
130+
if(not_empty)
131+
set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE)
132+
return()
133+
endif()
134+
135+
hunter_gate_fatal_error(
136+
"Can't detect HUNTER_ROOT"
137+
WIKI "error.detect.hunter.root"
138+
)
139+
endfunction()
140+
141+
# Must be a macro so master file 'cmake/Hunter' can
142+
# apply all variables easily just by 'include' command
143+
# (otherwise PARENT_SCOPE magic needed)
144+
macro(HunterGate)
145+
if(HUNTER_GATE_DONE)
146+
# variable HUNTER_GATE_DONE set explicitly for external project
147+
# (see `hunter_download`)
148+
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)
149+
endif()
150+
151+
# First HunterGate command will init Hunter, others will be ignored
152+
get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET)
153+
154+
if(_hunter_gate_done)
155+
hunter_gate_self(
156+
"${HUNTER_CACHED_ROOT}"
157+
"${HUNTER_VERSION}"
158+
"${HUNTER_SHA1}"
159+
_hunter_self
160+
)
161+
include("${_hunter_self}/cmake/Hunter")
162+
else()
163+
set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
164+
165+
if(PROJECT_NAME)
166+
167+
message("----------${PROJECT_NAME}")
168+
hunter_gate_fatal_error(
169+
"Please set HunterGate *before* 'project' command"
170+
WIKI "error.huntergate.before.project"
171+
)
172+
endif()
173+
174+
cmake_parse_arguments(
175+
HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV}
176+
)
177+
if(HUNTER_GATE_UNPARSED_ARGUMENTS)
178+
hunter_gate_user_error(
179+
"HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}"
180+
)
181+
endif()
182+
if(HUNTER_GATE_GLOBAL)
183+
if(HUNTER_GATE_LOCAL)
184+
hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)")
185+
endif()
186+
if(HUNTER_GATE_FILEPATH)
187+
hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)")
188+
endif()
189+
endif()
190+
if(HUNTER_GATE_LOCAL)
191+
if(HUNTER_GATE_GLOBAL)
192+
hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)")
193+
endif()
194+
if(HUNTER_GATE_FILEPATH)
195+
hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)")
196+
endif()
197+
endif()
198+
if(HUNTER_GATE_FILEPATH)
199+
if(HUNTER_GATE_GLOBAL)
200+
hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)")
201+
endif()
202+
if(HUNTER_GATE_LOCAL)
203+
hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)")
204+
endif()
205+
endif()
206+
207+
hunter_gate_detect_root() # set HUNTER_GATE_ROOT
208+
209+
# Beautify path, fix probable problems with windows path slashes
210+
get_filename_component(
211+
HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE
212+
)
213+
string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces)
214+
if(NOT _contain_spaces EQUAL -1)
215+
hunter_gate_fatal_error(
216+
"HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces"
217+
WIKI "error.spaces.in.hunter.root"
218+
)
219+
endif()
220+
221+
string(
222+
REGEX
223+
MATCH
224+
"[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*"
225+
HUNTER_GATE_VERSION
226+
"${HUNTER_GATE_URL}"
227+
)
228+
string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty)
229+
if(_is_empty)
230+
set(HUNTER_GATE_VERSION "unknown")
231+
endif()
232+
233+
hunter_gate_self(
234+
"${HUNTER_GATE_ROOT}"
235+
"${HUNTER_GATE_VERSION}"
236+
"${HUNTER_GATE_SHA1}"
237+
hunter_self_
238+
)
239+
240+
set(_master_location "${hunter_self_}/cmake/Hunter")
241+
if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter")
242+
# Hunter downloaded manually (e.g. by 'git clone')
243+
if(${DO_HUNTER_SYNC})
244+
execute_process( COMMAND git pull origin develop
245+
WORKING_DIRECTORY ${HUNTER_GATE_ROOT})
246+
endif()
247+
248+
set(_unused "xxxxxxxxxx")
249+
set(HUNTER_GATE_SHA1 "${_unused}")
250+
set(HUNTER_GATE_VERSION "${_unused}")
251+
else()
252+
hunter_gate_user_error(
253+
"Master file not found:"
254+
" ${_master_location}"
255+
"try to update Hunter/HunterGate"
256+
)
257+
endif()
258+
include("${_master_location}")
259+
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)
260+
endif()
261+
endmacro()

Release/cmake/cpprest_find_boost.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ function(cpprest_find_boost)
2323
return()
2424
endif()
2525

26+
if (HUNTER_ENABLED)
27+
# simplify: pull in max boost components we require
28+
add_definitions( -DBOOST_ALL_NO_LIB )
29+
hunter_add_package(Boost COMPONENTS random system thread filesystem chrono atomic date_time regex)
30+
find_package(Boost CONFIG REQUIRED random system thread filesystem chrono atomic date_time regex)
31+
else (HUNTER_ENABLED)
2632
if(IOS)
2733
if (EXISTS "${PROJECT_SOURCE_DIR}/../Build_iOS/boost")
2834
set(IOS_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../Build_iOS")
@@ -50,6 +56,7 @@ function(cpprest_find_boost)
5056
else()
5157
find_package(Boost REQUIRED COMPONENTS system date_time regex)
5258
endif()
59+
endif (HUNTER_ENABLED)
5360

5461
add_library(cpprestsdk_boost_internal INTERFACE)
5562
# FindBoost continually breaks imported targets whenever boost updates.

Release/cmake/cpprest_find_openssl.cmake

+16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ function(cpprest_find_openssl)
33
return()
44
endif()
55

6+
if (HUNTER_ENABLED)
7+
hunter_add_package(OpenSSL)
8+
find_package(OpenSSL REQUIRED)
9+
10+
INCLUDE(CheckCXXSourceCompiles)
11+
set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
12+
set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}")
13+
CHECK_CXX_SOURCE_COMPILES("
14+
#include <openssl/ssl.h>
15+
int main()
16+
{
17+
::SSL_COMP_free_compression_methods();
18+
}
19+
" _SSL_LEAK_SUPPRESS_AVAILABLE)
20+
else (HUNTER_ENABLED)
621
if(IOS)
722
set(IOS_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../Build_iOS")
823

@@ -64,6 +79,7 @@ function(cpprest_find_openssl)
6479
}
6580
" _SSL_LEAK_SUPPRESS_AVAILABLE)
6681
endif()
82+
endif (HUNTER_ENABLED)
6783

6884
add_library(cpprestsdk_openssl_internal INTERFACE)
6985
if(TARGET OpenSSL::SSL)

0 commit comments

Comments
 (0)