Skip to content

Commit b3f7e2b

Browse files
author
Adam Law
committed
2 parents a3ff6d8 + c4683b2 commit b3f7e2b

File tree

18 files changed

+632
-72
lines changed

18 files changed

+632
-72
lines changed

.github/CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ working docker setup to make the full test suite pass.
1515
1. build vendorized gtest: `./utils/build_gtest.sh`
1616
2. build restclient-cpp: `./autogen.sh && ./configure && make check`
1717
3. run the unit test suite: `make ci`
18+
19+
## Help wanted
20+
Given that I'm not in a position to maintain compatibility with all the different
21+
platforms, contributions around these are especially appreciated. I try to label
22+
issues accordingly. Some examples are:
23+
- [windows support](https://github.com/mrtazz/restclient-cpp/labels/windows)
24+
- [debian build problems](https://github.com/mrtazz/restclient-cpp/labels/debian)

.github/ISSUE_TEMPLATE.md renamed to .github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
110
### Expected behaviour
211

312
### Actual behaviour
4-
513
### Environment and debugging details
614

715
- compiler and version
816
- operating system
17+
- version of restclient-cpp
18+
- how did you install restclient-cpp? (via packages, git, tarball)
919
- libcurl version and compile flags
1020
- full error output of your build as an inline codeblock or gist
1121

.gitignore

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ config*
88
*aclocal.m4
99
*Makefile
1010
*Makefile.in
11-
vendor/gtest-1.7.0/scripts/gtest-config
12-
vendor/gtest-1.7.0/build-aux/config.h
13-
vendor/gtest-1.7.0/build-aux/config.h.in
14-
vendor/gtest-1.7.0/build-aux/ltmain.sh
15-
vendor/gtest-1.7.0/m4/ltoptions.m4
16-
vendor/gtest-1.7.0/m4/ltversion.m4
17-
vendor/jsoncpp-0.10.5/dist/.deps/jsoncpp.Po
11+
vendor/*
1812
test-program
1913
.libs
2014

15+
restclient-cpp.pc
16+
2117
*autom4te.cache
2218
*aclocal.m4
2319
*compile
@@ -43,3 +39,4 @@ usr
4339

4440
# generated files
4541
include/restclient-cpp/version.h
42+
arm-poky-linux-gnueabi-libtool

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: cpp
2-
dist: trusty
2+
dist: xenial
33
sudo: required
44
group: beta
55

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
11
# Changelog
22

3+
## v0.5.2 (12th February 2020)
4+
- add a pkg-config setup
5+
- Use the standard CMake-flag BUILD_SHARED_LIBS. (tastytea)
6+
- Add CURL and Threads as dependency in CMake config. (tastytea)
7+
- Replace hardcoded installation directories with GNUInstallDirs. (tastytea)
8+
- Set minimum CMake version to 3.12.0 (tastytea)
9+
- Added default compile type to CMakeLists.txt (Jorge Marizan)
10+
- Added configurable compile type to CMakeLists.txt (Jorge Marizan)
11+
- use lambda over ptr_fun (Cynthia Coan)
12+
- mac os x uses glibtoolize not libtoolize (Cynthia Coan)
13+
- Use std::make_unique when C++14 is available (Heikki Hellgren)
14+
- fix git version problems during yocto build (Giuseppe Ursino)
15+
- fix autogen to work with yocto (Giuseppe Ursino)
16+
- fix relative path issues (Giuseppe Ursino)
17+
- Added support for Unix sockets. (Dennis Jenkins)
18+
- update CI dist to xenial (Daniel Schauenberg)
19+
20+
## v0.5.1 (6th May 2019)
21+
- add initial cmake build
22+
- switch httpbin tests over to https
23+
24+
## v0.5.0 (31st October 2018)
25+
26+
### Features
27+
* Add PATCH and OPTIONS methods (#106) (drodil)
28+
* Add support for limiting the number of redirects (Bas van Kervel)
29+
* Added web proxy tunneling support. (amzoughi)
30+
* add client cert & key support (Fan Zhang)
31+
* add HEAD method (limhyungseok)
32+
* no-signal capability (Chris Kruger)
33+
34+
### Improvements and fixes
35+
* Remove duplicate FollowRedirects function (#109) (drodil)
36+
* Changed content type to application/json (Hajder Rabiee)
37+
* fix link to CONTRIBUTING guidelines (Daniel Schauenberg)
38+
* update distro repositories to push packages to (Daniel Schauenberg)
39+
* fix isspace is not a member of std with Visual Studio 2017 (Yoann Long)
40+
* add CODE_OF_CONDUCT.md (Daniel Schauenberg)
41+
* fix linter error for redundant blank line (Daniel Schauenberg)
42+
* remove unneeded curl include in restclient.h (Daniel Schauenberg)
43+
* Make SetProxy behave like curl's CURLOPT_PROXY (Daniel Schauenberg)
44+
* change prefixed address for proxy to HTTP (Daniel Schauenberg)
45+
* add unit test for http2 connection (Daniel Schauenberg)
46+
* move docker setup into Makefile (Daniel Schauenberg)
47+
* update CONTRIBUTING docs with proxy server details (Daniel Schauenberg)
48+
* add proxy server as docker service (Daniel Schauenberg)
49+
* default to 10s timeout in unit tests (Daniel Schauenberg)
50+
* update docs for HTTPS user certificate feature (Daniel Schauenberg)
51+
* add .github folder with issue/PR templates (Daniel Schauenberg)
52+
* move CI to run on travis trusty beta (Daniel Schauenberg)
53+
* Small optimizations (Martin Gerhardy)
54+
* Fix -Wpedantic warning (Daniel Perez)
55+
* fix README examples for conn->post, conn->put (Daniel Schauenberg)
56+
* add OSX install instructions to README (Daniel Schauenberg)
57+
358
## v0.4.4 (13th May 2016)
459
- bump version because v0.4.3 was mistagged
560

CMakeLists.txt

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
2+
cmake_minimum_required(VERSION 3.12.0)
3+
4+
project(restclient-cpp
5+
VERSION 0.5.2
6+
DESCRIPTION "REST client for C++"
7+
HOMEPAGE_URL "http://code.mrtazz.com/restclient-cpp"
8+
)
9+
set(restclient-cpp_VENDOR "[email protected]")
10+
set(PROJECT_VENDOR "${restclient-cpp_VENDOR}")
11+
12+
message(STATUS "Configured for: ${CMAKE_BUILD_TYPE}")
13+
add_custom_target(BeginMessage ALL
14+
${CMAKE_COMMAND} -E cmake_echo_color --white "Compiling for: $<CONFIG>"
15+
COMMENT "Compile Info" )
16+
17+
set(CMAKE_DEBUG_POSTFIX d)
18+
19+
set(CMAKE_CXX_STANDARD 11)
20+
21+
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
22+
23+
24+
if(POLICY CMP0074)
25+
cmake_policy(SET CMP0074 NEW)
26+
endif()
27+
28+
include(CheckIncludeFiles)
29+
30+
find_package(GTest)
31+
if(GTEST_FOUND)
32+
set(Gtest_FOUND TRUE)
33+
endif()
34+
if(GTest_FOUND)
35+
include(GoogleTest)
36+
endif()
37+
38+
find_package(Threads REQUIRED)
39+
find_package(CURL REQUIRED)
40+
find_package(jsoncpp)
41+
42+
option(BUILD_SHARED_LIBS "Build shared library." YES)
43+
if(COMPILE_TYPE STREQUAL "SHARED")
44+
set(BUILD_SHARED_LIBS YES)
45+
endif()
46+
47+
add_library(restclient-cpp
48+
source/restclient.cc
49+
source/connection.cc
50+
source/helpers.cc
51+
)
52+
set_property(TARGET restclient-cpp PROPERTY SOVERSION 2.1.1)
53+
54+
target_compile_features(restclient-cpp PUBLIC cxx_std_11)
55+
56+
list(APPEND restclient-cpp_PUBLIC_HEADERS
57+
include/restclient-cpp/restclient.h
58+
"${CMAKE_CURRENT_BINARY_DIR}/include/restclient-cpp/version.h"
59+
include/restclient-cpp/connection.h
60+
include/restclient-cpp/helpers.h
61+
)
62+
# target_sources(restclient-cpp PRIVATE ${restclient-cpp_PUBLIC_HEADERS})
63+
set_property(TARGET restclient-cpp PROPERTY
64+
PUBLIC_HEADER ${restclient-cpp_PUBLIC_HEADERS})
65+
target_include_directories(restclient-cpp PRIVATE include)
66+
67+
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/version.h.in")
68+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version.h.in" [=[
69+
#ifndef INCLUDE_RESTCLIENT_CPP_VERSION_H_
70+
#define INCLUDE_RESTCLIENT_CPP_VERSION_H_
71+
#define RESTCLIENT_VERSION "@restclient-cpp_VERSION@"
72+
#endif // INCLUDE_RESTCLIENT_CPP_VERSION_H_
73+
]=])
74+
endif()
75+
configure_file("${CMAKE_CURRENT_BINARY_DIR}/version.h.in"
76+
"${CMAKE_CURRENT_BINARY_DIR}/include/restclient-cpp/version.h")
77+
target_include_directories(restclient-cpp PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include")
78+
79+
target_link_libraries(restclient-cpp
80+
PUBLIC CURL::libcurl
81+
PUBLIC Threads::Threads
82+
)
83+
84+
include(GNUInstallDirs)
85+
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/restclient-cpp" )
86+
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/restclient-cpp" )
87+
set(RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" )
88+
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" )
89+
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/restclient-cpp" )
90+
91+
install(TARGETS restclient-cpp EXPORT restclient-cppTargets
92+
PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}
93+
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
94+
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
95+
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
96+
RESOURCE DESTINATION ${DATA_INSTALL_DIR}
97+
)
98+
99+
include(CMakePackageConfigHelpers)
100+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake.in"
101+
"@PACKAGE_INIT@\n"
102+
"include(CMakeFindDependencyMacro)\n"
103+
"find_dependency(CURL REQUIRED)\n"
104+
"find_dependency(Threads REQUIRED)\n"
105+
"include(\${CMAKE_CURRENT_LIST_DIR}/\@PROJECT_NAME\@Targets.cmake)\n")
106+
configure_package_config_file(
107+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake.in
108+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
109+
INSTALL_DESTINATION
110+
${CMAKE_INSTALL_PREFIX}/${CONFIG_INSTALL_DIR}
111+
PATH_VARS
112+
INCLUDE_INSTALL_DIR
113+
CONFIG_INSTALL_DIR
114+
RUNTIME_INSTALL_DIR
115+
LIB_INSTALL_DIR
116+
DATA_INSTALL_DIR
117+
)
118+
119+
write_basic_package_version_file(
120+
"${CMAKE_CURRENT_BINARY_DIR}/restclient-cppConfigVersion.cmake"
121+
COMPATIBILITY
122+
SameMajorVersion
123+
)
124+
125+
# export targets for find_package config mode
126+
install(EXPORT restclient-cppTargets DESTINATION ${CONFIG_INSTALL_DIR})
127+
128+
install(
129+
FILES
130+
${CMAKE_CURRENT_BINARY_DIR}/restclient-cppConfig.cmake
131+
${CMAKE_CURRENT_BINARY_DIR}/restclient-cppConfigVersion.cmake
132+
DESTINATION
133+
${CMAKE_INSTALL_PREFIX}/${CONFIG_INSTALL_DIR}
134+
)
135+
136+
if(Gtest_FOUND AND jsoncpp_FOUND)
137+
138+
enable_testing()
139+
140+
141+
add_executable(test-program
142+
vendor/jsoncpp-0.10.5/dist/jsoncpp.cpp
143+
test/tests.cpp
144+
test/test_restclient.cc
145+
test/test_connection.cc
146+
test/test_helpers.cc
147+
)
148+
target_include_directories(test-program
149+
PRIVATE include
150+
PRIVATE vendor/jsoncpp-0.10.5/dist
151+
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include")
152+
153+
target_link_libraries(test-program
154+
PUBLIC restclient-cpp
155+
PUBLIC GTest::GTest
156+
)
157+
gtest_discover_tests(test-program
158+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
159+
EXTRA_ARGS -VV
160+
)
161+
162+
endif()
163+
164+
165+
# TODO: Setup ctest here for valgrind and CI
166+
167+
# TODO: Setup cpack here for automatic packaging.
168+
# Note most of the work is already done above due to use of properties and install commands.
169+
170+
include(FeatureSummary)
171+
feature_summary(WHAT ALL)
172+
173+

Makefile.am

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
ACLOCAL_AMFLAGS=-I m4
2-
CPPFLAGS=-Iinclude
2+
CPPFLAGS=-I${top_srcdir}/include
33
check_PROGRAMS = test-program
44
pkginclude_HEADERS = include/restclient-cpp/restclient.h include/restclient-cpp/version.h include/restclient-cpp/connection.h include/restclient-cpp/helpers.h
55
BUILT_SOURCES = include/restclient-cpp/version.h
66

7-
test_program_SOURCES = vendor/jsoncpp-0.10.5/dist/jsoncpp.cpp test/tests.cpp test/test_restclient.cc test/test_connection.cc
7+
test_program_SOURCES = vendor/jsoncpp-0.10.5/dist/jsoncpp.cpp test/tests.cpp test/test_helpers.cc test/test_restclient.cc test/test_connection.cc
88
test_program_LDADD = .libs/librestclient-cpp.a
99
test_program_LDFLAGS=-Lvendor/gtest-1.7.0/lib/.libs -lgtest
10-
test_program_CPPFLAGS=-Iinclude -Ivendor/gtest-1.7.0/include -Ivendor/jsoncpp-0.10.5/dist
10+
test_program_CPPFLAGS=-std=c++11 -Iinclude -Ivendor/gtest-1.7.0/include -Ivendor/jsoncpp-0.10.5/dist
1111

1212
lib_LTLIBRARIES=librestclient-cpp.la
1313
librestclient_cpp_la_SOURCES=source/restclient.cc source/connection.cc source/helpers.cc
14-
librestclient_cpp_la_CXXFLAGS=-fPIC
14+
librestclient_cpp_la_CXXFLAGS=-fPIC -std=c++11
1515
librestclient_cpp_la_LDFLAGS=-version-info 2:1:1
1616

1717
dist_doc_DATA = README.md
1818

1919
.PHONY: test check clean-coverage-files coverage-html include/restclient-cpp/version.h lint ci docker-services
2020

2121
include/restclient-cpp/version.h:
22-
m4 -I m4 -DM4_RESTCLIENT_VERSION=$(VERSION) version.h.m4 > $@
22+
m4 -I ${top_srcdir}/m4 -DM4_RESTCLIENT_VERSION=$(PACKAGE_VERSION) version.h.m4 > ${top_srcdir}/$@
23+
24+
2325

2426
test: check
2527
./test-program

0 commit comments

Comments
 (0)