Skip to content

Commit 8a97c3a

Browse files
committed
Add cmake files for Beast, cryptopp, date, rapidjson
DownloadProject taken from https://github.com/Crascit/DownloadProject
1 parent 0eef9bf commit 8a97c3a

9 files changed

+284
-15
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/CMakeLists.txt.user

Beast/CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright Ben Pope 2017.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
include(DownloadProject)
7+
download_project(
8+
PROJ Beast
9+
GIT_REPOSITORY https://github.com/vinniefalco/Beast.git
10+
GIT_TAG ${BEAST_GIT_TAG}
11+
UPDATE_DISCONNECTED 1
12+
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Beast
13+
)
14+
15+
add_library(Beast INTERFACE)
16+
target_include_directories(Beast INTERFACE
17+
${Beast_SOURCE_DIR}/include
18+
${Beast_SOURCE_DIR}/extras
19+
)

CMakeLists.txt

+10-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
# http://www.boost.org/LICENSE_1_0.txt)
55

66
cmake_minimum_required(VERSION 3.3)
7-
project(pusher++_super CXX)
7+
project(pusher++ CXX)
88

9+
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
910
set(CMAKE_CXX_EXTENSIONS OFF)
1011

11-
add_library(tz date/tz.cpp)
12-
target_include_directories(tz INTERFACE
13-
${CMAKE_CURRENT_SOURCE_DIR}
14-
)
15-
target_compile_features(tz PUBLIC
16-
cxx_lambda_init_captures # forces C++14
17-
)
12+
set(BEAST_GIT_TAG 797631c) # 1.0.0-b24
13+
set(CRYPTOPP_GIT_TAG CRYPTOPP_5_6_5)
14+
set(DATE_GIT_TAG 2.1.0)
15+
set(RAPIDJSON_GIT_TAG v1.1.0)
1816

17+
add_subdirectory(cryptopp)
18+
add_subdirectory(date)
19+
add_subdirectory(rapidjson)
20+
add_subdirectory(Beast)
1921
add_subdirectory(pusher++)
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 2.8.2)
2+
3+
project(${DL_ARGS_PROJ}-download NONE)
4+
5+
include(ExternalProject)
6+
ExternalProject_Add(${DL_ARGS_PROJ}-download
7+
${DL_ARGS_UNPARSED_ARGUMENTS}
8+
SOURCE_DIR "${DL_ARGS_SOURCE_DIR}"
9+
BINARY_DIR "${DL_ARGS_BINARY_DIR}"
10+
CONFIGURE_COMMAND ""
11+
BUILD_COMMAND ""
12+
INSTALL_COMMAND ""
13+
TEST_COMMAND ""
14+
)

cmake/DownloadProject.cmake

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# MODULE: DownloadProject
2+
#
3+
# PROVIDES:
4+
# download_project( PROJ projectName
5+
# [PREFIX prefixDir]
6+
# [DOWNLOAD_DIR downloadDir]
7+
# [SOURCE_DIR srcDir]
8+
# [BINARY_DIR binDir]
9+
# [QUIET]
10+
# ...
11+
# )
12+
#
13+
# Provides the ability to download and unpack a tarball, zip file, git repository,
14+
# etc. at configure time (i.e. when the cmake command is run). How the downloaded
15+
# and unpacked contents are used is up to the caller, but the motivating case is
16+
# to download source code which can then be included directly in the build with
17+
# add_subdirectory() after the call to download_project(). Source and build
18+
# directories are set up with this in mind.
19+
#
20+
# The PROJ argument is required. The projectName value will be used to construct
21+
# the following variables upon exit (obviously replace projectName with its actual
22+
# value):
23+
#
24+
# projectName_SOURCE_DIR
25+
# projectName_BINARY_DIR
26+
#
27+
# The SOURCE_DIR and BINARY_DIR arguments are optional and would not typically
28+
# need to be provided. They can be specified if you want the downloaded source
29+
# and build directories to be located in a specific place. The contents of
30+
# projectName_SOURCE_DIR and projectName_BINARY_DIR will be populated with the
31+
# locations used whether you provide SOURCE_DIR/BINARY_DIR or not.
32+
#
33+
# The DOWNLOAD_DIR argument does not normally need to be set. It controls the
34+
# location of the temporary CMake build used to perform the download.
35+
#
36+
# The PREFIX argument can be provided to change the base location of the default
37+
# values of DOWNLOAD_DIR, SOURCE_DIR and BINARY_DIR. If all of those three arguments
38+
# are provided, then PREFIX will have no effect. The default value for PREFIX is
39+
# CMAKE_BINARY_DIR.
40+
#
41+
# The QUIET option can be given if you do not want to show the output associated
42+
# with downloading the specified project.
43+
#
44+
# In addition to the above, any other options are passed through unmodified to
45+
# ExternalProject_Add() to perform the actual download, patch and update steps.
46+
# The following ExternalProject_Add() options are explicitly prohibited (they
47+
# are reserved for use by the download_project() command):
48+
#
49+
# CONFIGURE_COMMAND
50+
# BUILD_COMMAND
51+
# INSTALL_COMMAND
52+
# TEST_COMMAND
53+
#
54+
# Only those ExternalProject_Add() arguments which relate to downloading, patching
55+
# and updating of the project sources are intended to be used. Also note that at
56+
# least one set of download-related arguments are required.
57+
#
58+
# If using CMake 3.2 or later, the UPDATE_DISCONNECTED option can be used to
59+
# prevent a check at the remote end for changes every time CMake is run
60+
# after the first successful download. See the documentation of the ExternalProject
61+
# module for more information. It is likely you will want to use this option if it
62+
# is available to you. Note, however, that the ExternalProject implementation contains
63+
# bugs which result in incorrect handling of the UPDATE_DISCONNECTED option when
64+
# using the URL download method or when specifying a SOURCE_DIR with no download
65+
# method. Fixes for these have been created, the last of which is scheduled for
66+
# inclusion in CMake 3.8.0. Details can be found here:
67+
#
68+
# https://gitlab.kitware.com/cmake/cmake/commit/bdca68388bd57f8302d3c1d83d691034b7ffa70c
69+
# https://gitlab.kitware.com/cmake/cmake/issues/16428
70+
#
71+
# If you experience build errors related to the update step, consider avoiding
72+
# the use of UPDATE_DISCONNECTED.
73+
#
74+
# EXAMPLE USAGE:
75+
#
76+
# include(download_project.cmake)
77+
# download_project(PROJ googletest
78+
# GIT_REPOSITORY https://github.com/google/googletest.git
79+
# GIT_TAG master
80+
# UPDATE_DISCONNECTED 1
81+
# QUIET
82+
# )
83+
#
84+
# add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
85+
#
86+
#========================================================================================
87+
88+
89+
set(_DownloadProjectDir "${CMAKE_CURRENT_LIST_DIR}")
90+
91+
include(CMakeParseArguments)
92+
93+
function(download_project)
94+
95+
set(options QUIET)
96+
set(oneValueArgs
97+
PROJ
98+
PREFIX
99+
DOWNLOAD_DIR
100+
SOURCE_DIR
101+
BINARY_DIR
102+
# Prevent the following from being passed through
103+
CONFIGURE_COMMAND
104+
BUILD_COMMAND
105+
INSTALL_COMMAND
106+
TEST_COMMAND
107+
)
108+
set(multiValueArgs "")
109+
110+
cmake_parse_arguments(DL_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
111+
112+
# Hide output if requested
113+
if (DL_ARGS_QUIET)
114+
set(OUTPUT_QUIET "OUTPUT_QUIET")
115+
else()
116+
unset(OUTPUT_QUIET)
117+
message(STATUS "Downloading/updating ${DL_ARGS_PROJ}")
118+
endif()
119+
120+
# Set up where we will put our temporary CMakeLists.txt file and also
121+
# the base point below which the default source and binary dirs will be
122+
if (NOT DL_ARGS_PREFIX)
123+
set(DL_ARGS_PREFIX "${CMAKE_BINARY_DIR}")
124+
endif()
125+
if (NOT DL_ARGS_DOWNLOAD_DIR)
126+
set(DL_ARGS_DOWNLOAD_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-download")
127+
endif()
128+
129+
# Ensure the caller can know where to find the source and build directories
130+
if (NOT DL_ARGS_SOURCE_DIR)
131+
set(DL_ARGS_SOURCE_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-src")
132+
endif()
133+
if (NOT DL_ARGS_BINARY_DIR)
134+
set(DL_ARGS_BINARY_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-build")
135+
endif()
136+
set(${DL_ARGS_PROJ}_SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" PARENT_SCOPE)
137+
set(${DL_ARGS_PROJ}_BINARY_DIR "${DL_ARGS_BINARY_DIR}" PARENT_SCOPE)
138+
139+
# Create and build a separate CMake project to carry out the download.
140+
# If we've already previously done these steps, they will not cause
141+
# anything to be updated, so extra rebuilds of the project won't occur.
142+
configure_file("${_DownloadProjectDir}/DownloadProject.CMakeLists.cmake.in"
143+
"${DL_ARGS_DOWNLOAD_DIR}/CMakeLists.txt")
144+
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
145+
RESULT_VARIABLE result
146+
${OUTPUT_QUIET}
147+
WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}"
148+
)
149+
if(result)
150+
message(FATAL_ERROR "CMake step for ${DL_ARGS_PROJ} failed: ${result}")
151+
endif()
152+
execute_process(COMMAND ${CMAKE_COMMAND} --build .
153+
RESULT_VARIABLE result
154+
${OUTPUT_QUIET}
155+
WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}"
156+
)
157+
if(result)
158+
message(FATAL_ERROR "Build step for ${DL_ARGS_PROJ} failed: ${result}")
159+
endif()
160+
161+
endfunction()

cryptopp/CMakeLists.txt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright Ben Pope 2017.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
include(DownloadProject)
7+
download_project(
8+
PROJ cryptopp
9+
GIT_REPOSITORY https://github.com/weidai11/cryptopp.git
10+
GIT_TAG ${CRYPTOPP_GIT_TAG}
11+
UPDATE_DISCONNECTED 1
12+
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/crypto++
13+
)
14+
15+
add_library(cryptopp INTERFACE)
16+
target_include_directories(cryptopp INTERFACE
17+
${cryptopp_SOURCE_DIR}/..
18+
)
19+
target_compile_definitions(cryptopp INTERFACE
20+
-DCRYPTOPP_ENABLE_NAMESPACE_WEAK=1 # for MD5
21+
)
22+
23+
set(BUILD_SHARED OFF)
24+
set(BUILD_TESTING OFF)
25+
26+
add_subdirectory(crypto++)
27+
28+
target_link_libraries(cryptopp INTERFACE cryptopp-static)

date/CMakeLists.txt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright Ben Pope 2017.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
include(DownloadProject)
7+
download_project(
8+
PROJ date
9+
GIT_REPOSITORY https://github.com/HowardHinnant/date.git
10+
GIT_TAG ${DATE_GIT_TAG}
11+
UPDATE_DISCONNECTED 1
12+
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/date
13+
)
14+
15+
add_library(date INTERFACE)
16+
target_include_directories(date INTERFACE
17+
${date_SOURCE_DIR}/..
18+
)
19+
20+
add_library(tz
21+
${date_SOURCE_DIR}/tz.cpp
22+
)
23+
target_compile_features(tz PUBLIC
24+
cxx_lambda_init_captures # forces C++14
25+
)
26+
target_link_libraries(tz INTERFACE
27+
date
28+
)

pusher++/CMakeLists.txt

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ find_package(Boost REQUIRED COMPONENTS system)
99

1010
add_library(pusher++ INTERFACE)
1111
target_sources(pusher++ INTERFACE
12-
${CMAKE_CURRENT_SOURCE_DIR}/README.md
1312
${CMAKE_CURRENT_SOURCE_DIR}/include/pusher++/client.hpp
1413
${CMAKE_CURRENT_SOURCE_DIR}/include/pusher++/channel_proxy.hpp
1514
${CMAKE_CURRENT_SOURCE_DIR}/include/pusher++/event.hpp
@@ -22,19 +21,15 @@ target_sources(pusher++ INTERFACE
2221
)
2322
target_include_directories(pusher++ INTERFACE
2423
${Boost_INCLUDE_DIRS}
25-
${PROJECT_SOURCE_DIR}/Beast/include
26-
${PROJECT_SOURCE_DIR}/rapidjson-1.1.0/include
2724
${PROJECT_SOURCE_DIR}/pusher++/include
2825
)
29-
target_compile_definitions(pusher++ INTERFACE
30-
-DCRYPTOPP_ENABLE_NAMESPACE_WEAK=1
31-
-DRAPIDJSON_HAS_STDSTRING=1
32-
)
3326
target_compile_features(pusher++ INTERFACE
3427
cxx_lambda_init_captures # forces C++14
3528
)
3629
target_link_libraries(pusher++ INTERFACE
30+
Beast
3731
${Boost_LIBRARIES}
32+
rapidjson
3833
cryptopp
3934
)
4035

rapidjson/CMakeLists.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright Ben Pope 2017.
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
include(DownloadProject)
7+
download_project(
8+
PROJ rapidjson
9+
GIT_REPOSITORY https://github.com/miloyip/rapidjson.git
10+
GIT_TAG ${RAPIDJSON_GIT_TAG}
11+
UPDATE_DISCONNECTED 1
12+
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/rapidjson
13+
)
14+
15+
add_library(rapidjson INTERFACE)
16+
target_include_directories(rapidjson INTERFACE
17+
${rapidjson_SOURCE_DIR}/include
18+
)
19+
target_compile_definitions(rapidjson INTERFACE
20+
-DRAPIDJSON_HAS_STDSTRING=1
21+
)

0 commit comments

Comments
 (0)