-
Notifications
You must be signed in to change notification settings - Fork 221
use boost-cmake again #359
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
Closed
ClausKlein
wants to merge
4
commits into
cpm-cmake:master
from
ClausKlein:feature/use-boost-cmake-again
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ parse: | |
| kwargs: | ||
| NAME: 1 | ||
| VERSION: 1 | ||
| NAMESPACE: 1 | ||
| INCLUDE_DIR: 1 | ||
| INCLUDE_DESTINATION: 1 | ||
| BINARY_DIR: 1 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,33 @@ | ||
| cmake_minimum_required(VERSION 3.14 FATAL_ERROR) | ||
| cmake_minimum_required(VERSION 3.14...3.26) | ||
|
|
||
| project(CPMExampleBoost) | ||
|
|
||
| # ---- Create binary ---- | ||
|
|
||
| add_executable(CPMExampleBoost main.cpp) | ||
| target_compile_features(CPMExampleBoost PRIVATE cxx_std_17) | ||
| add_executable(CPMExampleAsio deferred.cpp) | ||
| target_compile_features(CPMExampleAsio PRIVATE cxx_std_17) | ||
|
|
||
| add_executable(CPMExampleRegex regex.cpp) | ||
| target_compile_features(CPMExampleRegex PRIVATE cxx_std_17) | ||
|
|
||
| add_executable(CPMExampleTest const_string_test.cpp) | ||
| target_compile_features(CPMExampleTest PRIVATE cxx_std_17) | ||
|
|
||
| # ---- Dependencies ---- | ||
|
|
||
| include(../../cmake/CPM.cmake) | ||
|
|
||
| CPMAddPackage( | ||
| NAME Boost | ||
| VERSION 1.81.0 | ||
| GITHUB_REPOSITORY "boostorg/boost" | ||
| GIT_TAG "boost-1.81.0" | ||
| ) | ||
| # using unofficial fork as boost's lacking good CMake support for user | ||
| CPMAddPackage("gh:ClausKlein/boost-cmake@1.80.0") | ||
|
|
||
| target_link_libraries(CPMExampleAsio PRIVATE Boost::asio) | ||
| target_link_libraries(CPMExampleRegex PRIVATE Boost::regex) | ||
| target_link_libraries(CPMExampleTest PRIVATE Boost::unit_test_framework) | ||
|
|
||
| # ---- Testing ---- | ||
|
|
||
| enable_testing() | ||
|
|
||
| target_link_libraries(CPMExampleBoost PRIVATE Boost::asio) | ||
| add_test(NAME CPMExampleAsio COMMAND CPMExampleAsio) | ||
| add_test(NAME CPMExampleRegex COMMAND CPMExampleAsio) | ||
| add_test(NAME CPMExampleTest COMMAND CPMExampleTest) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| // (C) Copyright Gennadiy Rozental 2001-2014. | ||
| // Distributed under the Boost Software License, Version 1.0. | ||
| // (See accompanying file LICENSE_1_0.txt or copy at | ||
| // http://www.boost.org/LICENSE_1_0.txt) | ||
|
|
||
| // See http://www.boost.org/libs/test for the library home page. | ||
| // | ||
| // File : $RCSfile$ | ||
| // | ||
| // Version : $Revision$ | ||
| // | ||
| // Description : simple string class definition | ||
| // *************************************************************************** | ||
|
|
||
| #ifndef CONST_STRING_HPP | ||
| #define CONST_STRING_HPP | ||
|
|
||
| // STL | ||
| #include <cstring> | ||
| #include <iterator> | ||
| #include <string> | ||
| using std::string; | ||
|
|
||
| namespace common_layer { | ||
|
|
||
| // ************************************************************************** | ||
| // ************** const_string ************** | ||
| // ************************************************************************** | ||
|
|
||
| class const_string { | ||
| public: | ||
| // Subtypes | ||
| typedef char const* iterator; | ||
| typedef char const* const_iterator; | ||
| typedef std::reverse_iterator<iterator> reverse_iterator; | ||
| typedef reverse_iterator const_reverse_iterator; | ||
|
|
||
| // Constructor | ||
| const_string() : m_begin(""), m_end(m_begin) {} | ||
|
|
||
| // Copy constructor is generated by compiler | ||
|
|
||
| const_string(const std::string& s) : m_begin(s.c_str()), m_end(m_begin + s.length()) {} | ||
|
|
||
| const_string(char const* s) | ||
| : m_begin(s ? s : ""), m_end(s ? m_begin + std::strlen(s) : m_begin) {} | ||
|
|
||
| const_string(char const* s, size_t length) : m_begin(s), m_end(m_begin + length) { | ||
| if (length == 0) erase(); | ||
| } | ||
|
|
||
| const_string(char const* first, char const* last) : m_begin(first), m_end(last) {} | ||
|
|
||
| // data access methods | ||
| char operator[](size_t index) const { return m_begin[index]; } | ||
| char at(size_t index) const { return m_begin[index]; } | ||
|
|
||
| char const* data() const { return m_begin; } | ||
|
|
||
| // length operators | ||
| size_t length() const { return m_end - m_begin; } | ||
| bool is_empty() const { return m_end == m_begin; } | ||
|
|
||
| void erase() { m_begin = m_end = ""; } | ||
| void resize(size_t new_len) { | ||
| if (m_begin + new_len < m_end) m_end = m_begin + new_len; | ||
| } | ||
| void rshorten(size_t shift = 1) { | ||
| m_end -= shift; | ||
| if (m_end <= m_begin) erase(); | ||
| } | ||
| void lshorten(size_t shift = 1) { | ||
| m_begin += shift; | ||
| if (m_end <= m_begin) erase(); | ||
| } | ||
|
|
||
| // Assignment operators | ||
| const_string& operator=(const_string const& s); | ||
| const_string& operator=(string const& s) { return *this = const_string(s); } | ||
| const_string& operator=(char const* s) { return *this = const_string(s); } | ||
|
|
||
| const_string& assign(const_string const& s) { return *this = s; } | ||
| const_string& assign(string const& s, size_t len) { | ||
| return *this = const_string(s.data(), len); | ||
| } | ||
| const_string& assign(string const& s) { return *this = const_string(s); } | ||
| const_string& assign(char const* s) { return *this = const_string(s); } | ||
| const_string& assign(char const* s, size_t len) { return *this = const_string(s, len); } | ||
| const_string& assign(char const* f, char const* l) { return *this = const_string(f, l); } | ||
|
|
||
| void swap(const_string& s) { | ||
| // do not want to include alogrithm | ||
| char const* tmp1 = m_begin; | ||
| char const* tmp2 = m_end; | ||
|
|
||
| m_begin = s.m_begin; | ||
| m_end = s.m_end; | ||
|
|
||
| s.m_begin = tmp1; | ||
| s.m_end = tmp2; | ||
| } | ||
|
|
||
| // Comparison operators | ||
| friend bool operator==(const_string const& s1, const_string const& s2) { | ||
| return s1.length() == s2.length() && std::strncmp(s1.data(), s2.data(), s1.length()) == 0; | ||
| } | ||
| friend bool operator==(const_string const& s1, char const* s2) { | ||
| return s1 == const_string(s2); | ||
| } | ||
| friend bool operator==(const_string const& s1, const string& s2) { | ||
| return s1 == const_string(s2); | ||
| } | ||
|
|
||
| friend bool operator!=(const_string const& s1, const_string const& s2) { return !(s1 == s2); } | ||
| friend bool operator!=(const_string const& s1, char const* s2) { return !(s1 == s2); } | ||
| friend bool operator!=(const_string const& s1, const string& s2) { return !(s1 == s2); } | ||
|
|
||
| friend bool operator==(char const* s2, const_string const& s1) { return s1 == s2; } | ||
| friend bool operator==(const string& s2, const_string const& s1) { return s1 == s2; } | ||
|
|
||
| friend bool operator!=(char const* s2, const_string const& s1) { return !(s1 == s2); } | ||
| friend bool operator!=(const string& s2, const_string const& s1) { return !(s1 == s2); } | ||
|
|
||
| // Iterators | ||
| iterator begin() const { return m_begin; } | ||
| iterator end() const { return m_end; } | ||
| reverse_iterator rbegin() const { return reverse_iterator(m_end); } | ||
| reverse_iterator rend() const { return reverse_iterator(m_begin); } | ||
|
|
||
| private: | ||
| // Data members | ||
| char const* m_begin; | ||
| char const* m_end; | ||
| }; | ||
|
|
||
| //____________________________________________________________________________ | ||
|
|
||
| // first character | ||
| class first_char { | ||
| public: | ||
| char operator()(const_string source, char default_char = '\0') const { | ||
| return source.is_empty() ? default_char : *source.data(); | ||
| } | ||
| }; | ||
|
|
||
| //____________________________________________________________________________ | ||
|
|
||
| // last character | ||
| class last_char { | ||
| public: | ||
| char operator()(const_string source, char default_char = '\0') const { | ||
| return source.is_empty() ? default_char : *source.rbegin(); | ||
| } | ||
| }; | ||
|
|
||
| //____________________________________________________________________________ | ||
|
|
||
| inline const_string& const_string::operator=(const_string const& s) { | ||
| if (&s != this) { | ||
| m_begin = s.m_begin; | ||
| m_end = s.m_end; | ||
| } | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| //____________________________________________________________________________ | ||
|
|
||
| typedef const_string const literal; | ||
|
|
||
| //____________________________________________________________________________ | ||
|
|
||
| inline std::ostream& operator<<(std::ostream& os, const_string const& str) { | ||
| os << std::string(str.begin(), str.length()); | ||
|
|
||
| return os; | ||
| } | ||
|
|
||
| //____________________________________________________________________________ | ||
|
|
||
| }; // namespace common_layer | ||
|
|
||
| #endif // CONST_STRING_HPP |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.