-
Notifications
You must be signed in to change notification settings - Fork 74
Build with CMake #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
abea714
cbca1d7
68d4a19
4e8279c
4377af8
be52618
adefc53
db198b6
5ca1d9d
f821741
60d6856
9afd579
0cf244d
30b2cbb
d1cbd53
e4538d1
105bba9
7aedbbd
7428942
cda3474
32ed0e4
137c3a2
6e221b3
33c002d
9af28da
77f9e90
0a84c83
5d86a5b
b8fafca
be3b176
eae007e
dfd3251
03d98c8
7151e33
aed9d87
0bccc6b
ee7d002
7c63650
59c3097
5853d7b
c813012
fefb57e
07dc10b
89909e1
3ba1214
20f4dbb
5f0d6d7
3ae7a67
c8fe2d0
2b16d6e
f8ea96a
cdc8615
affde90
af7299b
04876d9
0b322b3
d422037
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,50 @@ | ||
cmake_minimum_required (VERSION 2.8.11) | ||
cmake_minimum_required (VERSION 3.5) | ||
|
||
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) | ||
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") | ||
endif() | ||
|
||
project (signalrclient) | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -L -lcpprest") | ||
include(CTest) | ||
|
||
if(NOT WIN32) | ||
set(EXTRA_FLAGS "-std=c++11 -fPIC -DNO_SIGNALRCLIENT_EXPORTS") | ||
else() | ||
set(EXTRA_FLAGS "-DSIGNALRCLIENT_EXPORTS") | ||
endif() | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}") | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_LDFLAGS}") | ||
|
||
set(CPPREST_INCLUDE_DIR "" CACHE FILEPATH "Path to casablanca include dir") | ||
find_package(cpprestsdk REQUIRED) | ||
set(CPPREST_LIB "cpprestsdk::cpprest") | ||
|
||
include_directories ( | ||
include | ||
"${CPPREST_INCLUDE_DIR}") | ||
include_directories (include) | ||
|
||
find_library(CPPREST_SO NAMES "cpprest" PATHS ${CPPREST_LIB_DIR} REQUIRED) | ||
# TODO: We shouldn't use this, it makes the dll/lib export all symbols | ||
# We need this for testing, but we might just add all the files to the test project manually | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We recommend against using We would instead recommend one of:
|
||
|
||
if(NOT WIN32) | ||
if(APPLE) | ||
file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/*) | ||
list(REVERSE OPENSSL_ROOT_DIR) | ||
endif() | ||
|
||
find_package(OpenSSL 1.0.0 REQUIRED) | ||
find_package(Boost REQUIRED COMPONENTS system thread chrono) | ||
endif() | ||
|
||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) | ||
|
||
add_subdirectory(src/signalrclient) | ||
add_subdirectory(test) | ||
|
||
if(BUILD_TESTING) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() | ||
|
||
install(DIRECTORY include/ DESTINATION include/) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
Apache License | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Pilchie Could you verify that this is the correct License file? Copied it from https://github.com/aspnet/AspNetCore |
||
Version 2.0, January 2004 | ||
http://www.apache.org/licenses/ | ||
|
||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | ||
|
||
1. Definitions. | ||
|
||
"License" shall mean the terms and conditions for use, reproduction, | ||
and distribution as defined by Sections 1 through 9 of this document. | ||
|
||
"Licensor" shall mean the copyright owner or entity authorized by | ||
the copyright owner that is granting the License. | ||
|
||
"Legal Entity" shall mean the union of the acting entity and all | ||
other entities that control, are controlled by, or are under common | ||
control with that entity. For the purposes of this definition, | ||
"control" means (i) the power, direct or indirect, to cause the | ||
direction or management of such entity, whether by contract or | ||
otherwise, or (ii) ownership of fifty percent (50%) or more of the | ||
outstanding shares, or (iii) beneficial ownership of such entity. | ||
|
||
"You" (or "Your") shall mean an individual or Legal Entity | ||
exercising permissions granted by this License. | ||
|
||
"Source" form shall mean the preferred form for making modifications, | ||
including but not limited to software source code, documentation | ||
source, and configuration files. | ||
|
||
"Object" form shall mean any form resulting from mechanical | ||
transformation or translation of a Source form, including but | ||
not limited to compiled object code, generated documentation, | ||
and conversions to other media types. | ||
|
||
"Work" shall mean the work of authorship, whether in Source or | ||
Object form, made available under the License, as indicated by a | ||
copyright notice that is included in or attached to the work | ||
(an example is provided in the Appendix below). | ||
|
||
"Derivative Works" shall mean any work, whether in Source or Object | ||
form, that is based on (or derived from) the Work and for which the | ||
editorial revisions, annotations, elaborations, or other modifications | ||
represent, as a whole, an original work of authorship. For the purposes | ||
of this License, Derivative Works shall not include works that remain | ||
separable from, or merely link (or bind by name) to the interfaces of, | ||
the Work and Derivative Works thereof. | ||
|
||
"Contribution" shall mean any work of authorship, including | ||
the original version of the Work and any modifications or additions | ||
to that Work or Derivative Works thereof, that is intentionally | ||
submitted to Licensor for inclusion in the Work by the copyright owner | ||
or by an individual or Legal Entity authorized to submit on behalf of | ||
the copyright owner. For the purposes of this definition, "submitted" | ||
means any form of electronic, verbal, or written communication sent | ||
to the Licensor or its representatives, including but not limited to | ||
communication on electronic mailing lists, source code control systems, | ||
and issue tracking systems that are managed by, or on behalf of, the | ||
Licensor for the purpose of discussing and improving the Work, but | ||
excluding communication that is conspicuously marked or otherwise | ||
designated in writing by the copyright owner as "Not a Contribution." | ||
|
||
"Contributor" shall mean Licensor and any individual or Legal Entity | ||
on behalf of whom a Contribution has been received by Licensor and | ||
subsequently incorporated within the Work. | ||
|
||
2. Grant of Copyright License. Subject to the terms and conditions of | ||
this License, each Contributor hereby grants to You a perpetual, | ||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
copyright license to reproduce, prepare Derivative Works of, | ||
publicly display, publicly perform, sublicense, and distribute the | ||
Work and such Derivative Works in Source or Object form. | ||
|
||
3. Grant of Patent License. Subject to the terms and conditions of | ||
this License, each Contributor hereby grants to You a perpetual, | ||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
(except as stated in this section) patent license to make, have made, | ||
use, offer to sell, sell, import, and otherwise transfer the Work, | ||
where such license applies only to those patent claims licensable | ||
by such Contributor that are necessarily infringed by their | ||
Contribution(s) alone or by combination of their Contribution(s) | ||
with the Work to which such Contribution(s) was submitted. If You | ||
institute patent litigation against any entity (including a | ||
cross-claim or counterclaim in a lawsuit) alleging that the Work | ||
or a Contribution incorporated within the Work constitutes direct | ||
or contributory patent infringement, then any patent licenses | ||
granted to You under this License for that Work shall terminate | ||
as of the date such litigation is filed. | ||
|
||
4. Redistribution. You may reproduce and distribute copies of the | ||
Work or Derivative Works thereof in any medium, with or without | ||
modifications, and in Source or Object form, provided that You | ||
meet the following conditions: | ||
|
||
(a) You must give any other recipients of the Work or | ||
Derivative Works a copy of this License; and | ||
|
||
(b) You must cause any modified files to carry prominent notices | ||
stating that You changed the files; and | ||
|
||
(c) You must retain, in the Source form of any Derivative Works | ||
that You distribute, all copyright, patent, trademark, and | ||
attribution notices from the Source form of the Work, | ||
excluding those notices that do not pertain to any part of | ||
the Derivative Works; and | ||
|
||
(d) If the Work includes a "NOTICE" text file as part of its | ||
distribution, then any Derivative Works that You distribute must | ||
include a readable copy of the attribution notices contained | ||
within such NOTICE file, excluding those notices that do not | ||
pertain to any part of the Derivative Works, in at least one | ||
of the following places: within a NOTICE text file distributed | ||
as part of the Derivative Works; within the Source form or | ||
documentation, if provided along with the Derivative Works; or, | ||
within a display generated by the Derivative Works, if and | ||
wherever such third-party notices normally appear. The contents | ||
of the NOTICE file are for informational purposes only and | ||
do not modify the License. You may add Your own attribution | ||
notices within Derivative Works that You distribute, alongside | ||
or as an addendum to the NOTICE text from the Work, provided | ||
that such additional attribution notices cannot be construed | ||
as modifying the License. | ||
|
||
You may add Your own copyright statement to Your modifications and | ||
may provide additional or different license terms and conditions | ||
for use, reproduction, or distribution of Your modifications, or | ||
for any such Derivative Works as a whole, provided Your use, | ||
reproduction, and distribution of the Work otherwise complies with | ||
the conditions stated in this License. | ||
|
||
5. Submission of Contributions. Unless You explicitly state otherwise, | ||
any Contribution intentionally submitted for inclusion in the Work | ||
by You to the Licensor shall be under the terms and conditions of | ||
this License, without any additional terms or conditions. | ||
Notwithstanding the above, nothing herein shall supersede or modify | ||
the terms of any separate license agreement you may have executed | ||
with Licensor regarding such Contributions. | ||
|
||
6. Trademarks. This License does not grant permission to use the trade | ||
names, trademarks, service marks, or product names of the Licensor, | ||
except as required for reasonable and customary use in describing the | ||
origin of the Work and reproducing the content of the NOTICE file. | ||
|
||
7. Disclaimer of Warranty. Unless required by applicable law or | ||
agreed to in writing, Licensor provides the Work (and each | ||
Contributor provides its Contributions) on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied, including, without limitation, any warranties or conditions | ||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | ||
PARTICULAR PURPOSE. You are solely responsible for determining the | ||
appropriateness of using or redistributing the Work and assume any | ||
risks associated with Your exercise of permissions under this License. | ||
|
||
8. Limitation of Liability. In no event and under no legal theory, | ||
whether in tort (including negligence), contract, or otherwise, | ||
unless required by applicable law (such as deliberate and grossly | ||
negligent acts) or agreed to in writing, shall any Contributor be | ||
liable to You for damages, including any direct, indirect, special, | ||
incidental, or consequential damages of any character arising as a | ||
result of this License or out of the use or inability to use the | ||
Work (including but not limited to damages for loss of goodwill, | ||
work stoppage, computer failure or malfunction, or any and all | ||
other commercial damages or losses), even if such Contributor | ||
has been advised of the possibility of such damages. | ||
|
||
9. Accepting Warranty or Additional Liability. While redistributing | ||
the Work or Derivative Works thereof, You may choose to offer, | ||
and charge a fee for, acceptance of support, warranty, indemnity, | ||
or other liability obligations and/or rights consistent with this | ||
License. However, in accepting such obligations, You may act only | ||
on Your own behalf and on Your sole responsibility, not on behalf | ||
of any other Contributor, and only if You agree to indemnify, | ||
defend, and hold each Contributor harmless for any liability | ||
incurred by, or claims asserted against, such Contributor by reason | ||
of your accepting any such warranty or additional liability. | ||
|
||
END OF TERMS AND CONDITIONS | ||
|
||
APPENDIX: How to apply the Apache License to your work. | ||
|
||
To apply the Apache License to your work, attach the following | ||
boilerplate notice, with the fields enclosed by brackets "[]" | ||
replaced with your own identifying information. (Don't include | ||
the brackets!) The text should be enclosed in the appropriate | ||
comment syntax for the file format. We also recommend that a | ||
file or class name and description of purpose be included on the | ||
same "printed page" as the copyright notice for easier | ||
identification within third-party archives. | ||
|
||
Copyright [yyyy] [name of copyright owner] | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,41 @@ | |
This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at https://github.com/aspnet/AspNetCore. | ||
|
||
Use https://github.com/aspnet/AspNetCore/issues for issues with this project. | ||
|
||
### Build on Windows ### | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should mention dependencies that need to be installed on non-macOs platform like cmake for Windows and cmake/"build-essentials"/gcc/g++ on linux. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try to gather that info and improve the readme at a later time. |
||
```powershell | ||
PS> git submodule update --init | ||
PS> .\submodules\vcpkg\bootstrap-vcpkg.bat | ||
PS> .\submodules\vcpkg\vcpkg.exe install cpprestsdk:x64-windows | ||
PS> mkdir build.release | ||
PS> cd build.release | ||
PS> cmake .. -A x64 -DCMAKE_TOOLCHAIN_FILE="..\submodules\vcpkg\scripts\buildsystems\vcpkg.cmake" -DCMAKE_BUILD_TYPE=Release | ||
PS> cmake --build . --config Release | ||
``` | ||
Output will be in `build.release\bin\Release\` | ||
|
||
### Build on Mac ### | ||
```bash | ||
$ git submodule update --init | ||
$ brew install gcc6 | ||
$ ./submodules/vcpkg/bootstrap-vcpkg.sh | ||
$ ./submodules/vcpkg/vcpkg install cpprestsdk | ||
$ mkdir build.release | ||
$ cd build.release | ||
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../submodules/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release | ||
$ cmake --build . --config Release | ||
``` | ||
Output will be in `build.release/bin/` | ||
|
||
### Build on Linux ### | ||
|
||
```bash | ||
$ git submodule update --init | ||
$ ./submodules/vcpkg/bootstrap-vcpkg.sh | ||
$ ./submodules/vcpkg/vcpkg install cpprestsdk boost-system boost-chrono boost-thread | ||
$ mkdir build.release | ||
$ cd build.release | ||
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../submodules/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release | ||
$ cmake --build . --config Release | ||
``` | ||
Output will be in `build.release/bin/` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,20 +5,24 @@ jobs: | |
- template: .azure/default-build.yml | ||
parameters: | ||
agentOs: Windows | ||
cMakeRunArgs: '-A x64' | ||
beforeBuild: | ||
- script: echo Hello, world! | ||
displayName: 'Run a one-line script' | ||
- powershell: "& vcpkg.exe install cpprestsdk:x64-windows --vcpkg-root ./submodules/vcpkg" | ||
displayName: vcpkg install dependencies | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we include this beforeBuild steps, extra cMakeRunArgs and the like for each OS in the README.md? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also be good to include instructions to run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh duh, I meant to add a readme... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. y'know what's even better than a README (though there should be one as well)? |
||
|
||
- template: .azure/default-build.yml | ||
parameters: | ||
agentOs: macOs | ||
beforeBuild: | ||
- script: echo Hello, world! | ||
displayName: 'Run a one-line script' | ||
- script: brew install gcc6 | ||
- bash: "./submodules/vcpkg/bootstrap-vcpkg.sh" | ||
displayName: Bootstrap vcpkg | ||
- bash: "./submodules/vcpkg/vcpkg install cpprestsdk" | ||
BrennanConroy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
displayName: vcpkg install dependencies | ||
|
||
- template: .azure/default-build.yml | ||
parameters: | ||
agentOs: Linux | ||
beforeBuild: | ||
- script: echo Hello, world! | ||
displayName: 'Run a one-line script' | ||
- script: sudo vcpkg install cpprestsdk boost-system boost-chrono boost-thread --vcpkg-root ./submodules/vcpkg | ||
displayName: vcpkg install dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent 24 minutes building/installing the cpprestsdk on my mac using
./submodules/vcpkg/vcpkg install cpprestsdk
(thanks C++/Boost), but when I run cmake, I get the following error:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same problem :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see the vcpkg folder on either (or both) of your machines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in the submodules/vcpkg directory? Mine is just what's in https://github.com/Microsoft/vcpkg/tree/d1110ceb7feb527ac58f274239d435e32dca4b84 without changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a bare minimum you should have a new file
vcpkg
that's runnable on your machine. But more importantly I'm looking for the submodules/vcpkg/installed folder.