generated from Sithas/conan_template
Compare commits
130 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b2695ee582 | |||
| 6d1a567369 | |||
| 2bcc250a24 | |||
| 1ca4120164 | |||
| eb187025eb | |||
| e0bb9025b1 | |||
| 87f1e4a735 | |||
| 7d19dcb69a | |||
| c384fdab7c | |||
| fb4ee8fedb | |||
| cd1a75eb88 | |||
| c72c0c5299 | |||
| ca3558be29 | |||
| 1eee06ed98 | |||
| fb96783ba4 | |||
| 7bf07c938b | |||
| be2c1ead61 | |||
| 14481fa055 | |||
| b131f9d4e8 | |||
| 07558a07c6 | |||
| 2a99fc727c | |||
| 04fb9b7ff4 | |||
| d0b098cec5 | |||
| 40f694df33 | |||
| ba3099dc6d | |||
| f982c185b0 | |||
| 2443831ca3 | |||
| b2b1ebe794 | |||
| 72f3603dd0 | |||
| 3a8d5ea6c1 | |||
| 31ed7f8531 | |||
| d2bd02fb47 | |||
| cb7a6a0bde | |||
| 17948a5213 | |||
| 04bbb64f2c | |||
| 2adca01007 | |||
| 2e931932e5 | |||
| c78a20e508 | |||
| b1f5712070 | |||
| 1d4a1366e1 | |||
| 8c1431165c | |||
| 4b2566b49d | |||
| 20531a6123 | |||
| dcbcacdd48 | |||
| b677d9b93b | |||
| 5468bff1da | |||
| e9417d9a29 | |||
| ffaf251051 | |||
| 4b83a29f78 | |||
| c464ef1a8d | |||
| e46af17132 | |||
| d18ace59a9 | |||
| 25fe40a8ad | |||
| 9112bc21db | |||
| ec3817fad6 | |||
| 5e18a1d2a9 | |||
| 6247bc1970 | |||
| 5f6285e372 | |||
| 03258ca4c3 | |||
| acdb77309f | |||
| 1a1fd07d55 | |||
| 60339d9195 | |||
| ea72d70594 | |||
| 942d5f3da9 | |||
| 516b65fc1a | |||
| 7321240e59 | |||
| 15cfa3a77c | |||
| d94d835db9 | |||
| bd9a01676c | |||
| 02a7e8f7c6 | |||
| 96ff767bd8 | |||
| 5688d99aea | |||
| f7977c14ca | |||
| 781e877463 | |||
| 96594db979 | |||
| 5faf10be72 | |||
| 2551031158 | |||
| 0daa81977b | |||
| 738700e8d8 | |||
| a5ad3c16b4 | |||
| 04a517dae5 | |||
| 3ec2978c06 | |||
| 8b693c75eb | |||
| b566bb569c | |||
| 9efa06a9c8 | |||
| e478ff5769 | |||
| 5fbaadaa79 | |||
| 11b2f1313a | |||
| e807dfd4b1 | |||
| 48fd51d01c | |||
| 95f2737cad | |||
| 9de7d75622 | |||
| a214bfd741 | |||
| 8392915580 | |||
| e630a7bdf5 | |||
| 9b1517c386 | |||
| 0bcf0eb825 | |||
| 0b381f2b25 | |||
| 471d3edda8 | |||
| 9308d5b038 | |||
| c27d77e0cf | |||
| 7db9cbf3f0 | |||
| 65eb49215f | |||
| 4e42c16c0f | |||
| 0c1896f54e | |||
| 5b83f2848a | |||
| ea2f7ab814 | |||
| ae0fe86743 | |||
| eb01897170 | |||
| 87fdd33d62 | |||
| 23849ba03a | |||
| dff8119f8b | |||
| e6ce15d422 | |||
| 412b83d4d1 | |||
| bf738e2bd2 | |||
| 581b104e85 | |||
| 50d2fad70a | |||
| 88e80e7030 | |||
| 0bb184e0f5 | |||
| 66bf85b310 | |||
| b3f48b6618 | |||
| 16fc7a044d | |||
| d2e849af3f | |||
| 8c11b46cbd | |||
| 2c3e50f78e | |||
| 78d4965e14 | |||
| 0b0702ab35 | |||
| f1d25388b4 | |||
| ac8ca9cd46 | |||
| f12df8f0ec |
@@ -0,0 +1,53 @@
|
||||
# Generated from CLion C/C++ Code Style settings
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignOperands: false
|
||||
AlignTrailingComments: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: true
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: true
|
||||
BeforeWhile: true
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBraces: Custom
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
ColumnLimit: 100
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ContinuationIndentWidth: 2
|
||||
IncludeCategories:
|
||||
- Regex: '^<.*'
|
||||
Priority: 1
|
||||
- Regex: '^".*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IndentCaseBlocks: true
|
||||
InsertNewlineAtEOF: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 2
|
||||
PointerAlignment: Left
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
TabWidth: 2
|
||||
...
|
||||
+70
-21
@@ -1,28 +1,77 @@
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
cmake_minimum_required(VERSION 3.29.8)
|
||||
project(UpAndDown)
|
||||
|
||||
project(App CXX)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
|
||||
find_package(Boost 1.84.0 REQUIRED)
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
if(POLICY CMP0167)
|
||||
cmake_policy(SET CMP0167 OLD)
|
||||
endif()
|
||||
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_INCLUDE_DIR ${BOOST_ROOT})
|
||||
set(Boost_LIBRARY_DIR "${BOOST_ROOT}/stage/lib")
|
||||
|
||||
find_package(Boost 1.88.0 REQUIRED COMPONENTS filesystem json log)
|
||||
if (Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
find_package(mysql-concpp REQUIRED)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
add_executable(application src/main.cpp
|
||||
src/helpers.h
|
||||
src/helper.cpp
|
||||
src/sdk.h
|
||||
src/Session.h
|
||||
src/Session.cpp
|
||||
src/Listener.h
|
||||
src/Listener.cpp
|
||||
src/content_type.h
|
||||
src/RequestHandlers/BasicRequestHandler.cpp
|
||||
src/RequestHandlers/BasicRequestHandler.h)
|
||||
target_link_libraries(application PRIVATE Threads::Threads)
|
||||
add_executable(App ./src/main.cpp
|
||||
./src/helpers/helpers.h
|
||||
./src/helpers/helpers.cpp
|
||||
./src/endpoints_handlers/HandleRequest.h
|
||||
./src/endpoints_handlers/IController.h
|
||||
./src/endpoints_handlers/Controller.h
|
||||
./src/session/HttpSession.h
|
||||
./src/session/HttpSession.cpp
|
||||
./src/session/WebsocketSession.h
|
||||
./src/session/WebsocketSession.cpp
|
||||
./src/listener/Listener.h
|
||||
./src/listener/Listener.cpp
|
||||
./src/db/mysql_connector.cpp
|
||||
./src/db/mysql_connector.h
|
||||
./src/DAO/IUserDAO.h
|
||||
./src/entities/user.h
|
||||
./src/DAO/MySQLUserDAO.cpp
|
||||
./src/DAO/MySQLUserDAO.h
|
||||
./src/endpoints_handlers/IExecutor.h
|
||||
./src/endpoints_handlers/AuthRegistrationExecutor.h
|
||||
./src/endpoints_handlers/RootExecutor.h
|
||||
./src/DAO/IAuthDAO.h
|
||||
./src/DAO/MemoryAuthDAO.cpp
|
||||
./src/DAO/MemoryAuthDAO.h
|
||||
./src/endpoints_handlers/AuthLogoutExecutor.h
|
||||
./src/exceptions/session_exception.cpp
|
||||
./src/exceptions/session_exception.h
|
||||
)
|
||||
|
||||
target_link_libraries(App PRIVATE Boost::boost Boost::json Threads::Threads mysql::concpp)
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
||||
endif ()
|
||||
|
||||
add_executable(HelpersTests ./tests/helpers/helpers_TEST.cpp
|
||||
./src/helpers/helpers.h
|
||||
./src/helpers/helpers.cpp)
|
||||
target_link_libraries(HelpersTests PRIVATE Boost::boost)
|
||||
add_test(HelpersTests HelpersTests)
|
||||
|
||||
add_executable(ControllerTests ./tests/endpoint_handlers/Controller_TEST.cpp
|
||||
./src/endpoints_handlers/IController.h
|
||||
./src/endpoints_handlers/Controller.h)
|
||||
target_link_libraries(ControllerTests PRIVATE Boost::boost)
|
||||
add_test(ControllerTests ControllerTests)
|
||||
|
||||
if (WIN32)
|
||||
target_compile_definitions(App PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||
target_compile_definitions(HelpersTests PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||
target_compile_definitions(ControllerTests PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
|
||||
endif()
|
||||
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<code_scheme name="Nihilus" version="173">
|
||||
<option name="AUTODETECT_INDENTS" value="false" />
|
||||
<option name="RIGHT_MARGIN" value="100" />
|
||||
<Objective-C>
|
||||
<option name="INDENT_CLASS_MEMBERS" value="2" />
|
||||
<option name="INDENT_VISIBILITY_KEYWORDS" value="1" />
|
||||
<option name="NAMESPACE_BRACE_PLACEMENT" value="2" />
|
||||
<option name="METHOD_BRACE_PLACEMENT" value="2" />
|
||||
<option name="FUNCTION_BRACE_PLACEMENT" value="2" />
|
||||
<option name="BLOCK_BRACE_PLACEMENT" value="2" />
|
||||
<option name="FUNCTION_PARAMETERS_WRAP" value="0" />
|
||||
<option name="FUNCTION_CALL_ARGUMENTS_WRAP" value="0" />
|
||||
<option name="CLASS_CONSTRUCTOR_INIT_LIST_WRAP" value="0" />
|
||||
<option name="CLASS_CONSTRUCTOR_INIT_LIST_NEW_LINE_BEFORE_COLON" value="1" />
|
||||
<option name="SPACE_WITHIN_EMPTY_BRACES" value="true" />
|
||||
<option name="SPACE_BEFORE_PROTOCOLS_BRACKETS" value="false" />
|
||||
<option name="SPACE_BEFORE_REFERENCE_IN_DECLARATION" value="false" />
|
||||
<option name="SPACE_AFTER_REFERENCE_IN_DECLARATION" value="true" />
|
||||
<option name="HEADER_GUARD_STYLE_PATTERN" value="_${FILE_NAME}_${EXT}_" />
|
||||
</Objective-C>
|
||||
<RiderCodeStyleSettings>
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="2" type="long" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="2" type="long" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Classes_0020and_0020structs/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Classes_0020and_0020structs/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Concepts/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Concepts/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Enums/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Enums/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Unions/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Unions/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Template_0020parameters/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Template_0020parameters/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Parameters/@EntryIndexedValue" value="<NamingElement Priority="2"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="function parameter" /><type Name="lambda parameter" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aa_bb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Local_0020variables/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Local_0020variables/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Global_0020variables/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Global_0020variables/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Global_0020functions/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Global_0020functions/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020methods/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020methods/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020fields/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020fields/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020public_0020fields/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020and_0020struct_0020public_0020fields/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Union_0020members/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Union_0020members/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Enumerators/@EntryIndexedValue" value="<NamingElement Priority="8"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="scoped enumerator" /><type Name="unscoped enumerator" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="k" Suffix="" Style="AaBb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Other_0020constants/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Other_0020constants/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Global_0020constants/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Global_0020constants/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Namespaces/@EntryIndexedValue" value="<NamingElement Priority="9"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="namespace" /><type Name="namespace alias" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aa_bb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Typedefs/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Typedefs/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Macros/@EntryIndexedValue" value="<NamingElement Priority="10"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="macro" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AA_BB" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Properties/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Properties/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Events/@EntryIndexedValue" value="" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Events/@EntryIndexRemoved" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Types/@EntryIndexedValue" value="<NamingElement Priority="1"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="__interface" /><type Name="class" /><type Name="concept" /><type Name="enum" /><type Name="struct" /><type Name="type alias" /><type Name="type template parameter" /><type Name="typedef" /><type Name="union" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Common_0020Variables/@EntryIndexedValue" value="<NamingElement Priority="3"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="global variable" /><type Name="local variable" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aa_bb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Struct_0020Data_0020Members/@EntryIndexedValue" value="<NamingElement Priority="4"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="struct field" /><type Name="union member" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aa_bb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Class_0020Data_0020Members/@EntryIndexedValue" value="<NamingElement Priority="5"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="class field" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="_" Style="aa_bb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Constants/@EntryIndexedValue" value="<NamingElement Priority="6"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="True" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="global variable" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="k" Suffix="" Style="AaBb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Functions/@EntryIndexedValue" value="<NamingElement Priority="7"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="global function" /><type Name="member function" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="" Style="aa_bb" /></Policy></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNaming/Rules/=Non_002DType_0020Template_0020Parameters/@EntryIndexedValue" value="<NamingElement Priority="11"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="non-type template parameter" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesInIfStatement/@EntryValue" value="Required" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesInForStatement/@EntryValue" value="Required" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesInWhileStatement/@EntryValue" value="Required" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesRedundant/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_CASE/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_LIMIT/@EntryValue" value="100" type="long" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="None" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/ExecutableToUse/@EntryValue" value="Custom" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/ExternalClangFormatPath/@EntryValue" value="C:\CLionProjects\UpAndDown\.clang-format" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0B82708A1BA7774EB13D27F245698A56/@EntryIndexedValue" value="<NamingElement Priority="1" Title="Classes and structs"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="__interface" /><type Name="class" /><type Name="struct" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="" Suffix="" Style="aa_bb" /></Policy></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=8F69F48E2532F54CBAA0039D4557825E/@EntryIndexedValue" value="<NamingElement Priority="10" Title="Global functions"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="global function" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B6E900853D6D05429D8C57765B2E546A/@EntryIndexedValue" value="<NamingElement Priority="11" Title="Class and struct methods"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="member function" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=4203BE6F332C5149B409B4D5F7197E54/@EntryIndexedValue" value="<NamingElement Priority="15" Title="Enumerators"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="scoped enumerator" /><type Name="unscoped enumerator" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=BF0D1AE66D64FE4FAF613448A12051A0/@EntryIndexedValue" value="<NamingElement Priority="17" Title="Global constants"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="True" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="global variable" /></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /></NamingElement>" type="string" />
|
||||
<option name="/Default/CodeStyle/CppIncludeDirective/SortIncludeDirectives/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/SortDefinitions/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINKAGE_SPECIFICATION_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/EXPRESSION_BRACES/@EntryValue" value="OUTSIDE_AND_INSIDE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_FIRST_ARG_BY_PAREN/@EntryValue" value="true" type="bool" />
|
||||
</RiderCodeStyleSettings>
|
||||
<codeStyleSettings language="ObjectiveC">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
@@ -0,0 +1,254 @@
|
||||
# TODO:
|
||||
|
||||
- ~~Сделать реальные исполнители(executors) для регистрации, авторизации, логаута~~
|
||||
- Посмотреть по поводу блокировок или тред пулла при использовании базы
|
||||
- Посмотреть пулл соединений(Object pool) при использовании базы данных(посмотреть api MySQL-Connector)
|
||||
- Посмотреть, что дает MySQL, какие там есть возможность
|
||||
- Посмотреть и подумать, что лучше - корутины или многопоточность?
|
||||
- Покрыть тестами класс User и AuthRegistrationExecutor
|
||||
- ~~Добавить clang-format(через CLion)~~
|
||||
- ~~Перевести GetByUUID GetByLogin на const ref/string_view в IUserDAO - также не vector, а span(погуглить)~~ - span не применим
|
||||
- ~~Привести к единому виду функции IUserDAO~~
|
||||
- ~~Пройтись по коду и максимально наставить const~~
|
||||
- ~~Указать возможные исключения в интерфейсах DAO - почему может выбросить исключение~~
|
||||
- ~~Вынести User в структуру. Hashed Password структура должна изначально состоять в другой структуре~~
|
||||
- ~~SharedPtr - передавать по константной ссылке.~~
|
||||
- ~~Вынести обработку исключений в RootExecutor~~
|
||||
- ~~Уменьшить дублирование кода в исключениях~~
|
||||
- Покрыть логами
|
||||
- ~~Сделать один класс исключений, имеющих метод HTTP code - код и сообщение записывать уже в ловушке~~
|
||||
- Сделать интеграционный тест по ручкам
|
||||
|
||||
# UseCase'ы приложения:
|
||||
|
||||
# Up And Down - система для учета и отслеживания состояния для людей, больных БАР
|
||||
|
||||
## UseCase №1
|
||||
### 1.Название: Зарегистрировать пользователя
|
||||
### 2.Актор: Пользователь
|
||||
### 3.Цель: Внести данные о новом пользователе в систему
|
||||
### 4.Предусловия:
|
||||
* Пользователь не авторизован в системе
|
||||
* Пользователь с данным login'ом отсутствует в системе
|
||||
### 5.Основной поток:
|
||||
#### А1.Пользователь при входе в систему выбрасывается из системы
|
||||
* Пользователь заходит в приложение на любую страницу
|
||||
* Из-за отсутсвия авторизации приложение перенаправляет его на страницу авторизации и регистрации
|
||||
* Пользователь кликает по ссылке, ведущей на странице регистрации
|
||||
* На странице регистрации пользователь вводит логин и пароль
|
||||
* Пользователь нажимает кнопку "Зарегистрироваться"
|
||||
* Система выводит сообщение, что пользователь зарегистрирован в приложении
|
||||
### 6.Потоки исключений:
|
||||
#### B1.Пользователь с таким логином уже есть в системе
|
||||
* Процедура регистрации проваливается
|
||||
* Выводится нотификация с сообщением об ошибке по причине наличия такого же логина в системе
|
||||
#### B2.Пользователь оставил пустым логин или пустой/неправильный пароль
|
||||
* При попытке регистрации подсвечиваются незаполненные поля, или поле пароля, если пароль неправильный
|
||||
* Выводится сообщение об ошибке
|
||||
### 7.Постусловия
|
||||
* Пользователь с указанным логином сохранен в БД
|
||||
### 8.API-Маршруты
|
||||
* `POST /api/v1/Auth/Register` - Регистрация пользователя
|
||||
### 9.Контракт
|
||||
#### Register-Request
|
||||
```
|
||||
{
|
||||
"login": "ivan_89",
|
||||
"password": "S3cureP@ssw0rd"
|
||||
}
|
||||
```
|
||||
##### Требования к валидации:
|
||||
* login: 3-50 символов, ^[A-Za-z0-9_]+$, уникальное значение
|
||||
* password: ≥ 5 символов
|
||||
|
||||
##### Response - 201 - Created
|
||||
```
|
||||
{
|
||||
"user": {
|
||||
"uuid": "51351bb1-7563-479d-a8e9-201d0ff934c2"
|
||||
"login": "ivan_89"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
##### Errors
|
||||
* `409 USER_EXISTS` — пользователь с таким логином уже есть(`B1`)
|
||||
* `422 VALIDATION_FAILED` — пустой логин/неправильный пароль(`B2`)
|
||||
* `400 BAD_REQUEST` — сервер не смог десереализовать JSON
|
||||
|
||||
### 10. Используемые сущности ДБ
|
||||
* users(uuid(PK), login(unique), hashed_password)
|
||||
|
||||
## UseCase №2
|
||||
### 1.Название: Авторизация пользователя
|
||||
### 2.Актор: Пользователь
|
||||
### 3.Цель: Предоставить пользователю возможность получить его данные в виде дневника болезни
|
||||
### 4.Предусловия:
|
||||
* Пользователь должен быть зарегистрирован в системе
|
||||
* Пользователь должен быть не авторизован в системе
|
||||
### 5.Основной поток:
|
||||
#### А1.Пользователь при входе в систему выбрасывается из системы
|
||||
* Пользователь заходит в приложение на любую страницу
|
||||
* Из-за отсутствия авторизации приложение перенаправляет его на страницу авторизации
|
||||
* Пользователь вводит свой логин и пароль
|
||||
* Пользователь получает токен, который открывает ему доступ к получению собственных данных
|
||||
#### А2.Пользователь осуществляет выход из системы
|
||||
* Пользователь кликает на кнопку логаута
|
||||
* На сервере происходил отзыв токена
|
||||
* Пользователь вновь считается неавторизованным
|
||||
### 6.Альтернативные потоки:
|
||||
#### B1.Введен неправильный логин или неправильный пароль
|
||||
* Пользователь не получает токен, авторизация провалена
|
||||
* Выводится сообщение об ошибке
|
||||
#### B2.Поле логин или пароль оставлены пустыми
|
||||
* При попытке авторизации не происходит запрос токена. Авторизация провалена
|
||||
* Пустые поля подкрашиваются, как ошибочно заполненные
|
||||
* Выводится сообщение об ошибке
|
||||
#### B3.Пользователь не был зарегистрирован в приложении на момент логаута
|
||||
* Сервер не может отозвать токен и возвращает ошибку
|
||||
### 7.Постусловия
|
||||
* Сессия пользователя в виде токена сохраняется на сервере
|
||||
* Пользователь перенаправлен на основную страницу, где выводится его дневник болезни
|
||||
### 8.API-Маршруты
|
||||
* `POST /api/v1/Auth/Login` - Вход пользователя в систему и получение токена
|
||||
* `POST /api/v1/Auth/Logout` - Отозвать токен и выйти из системы.
|
||||
### 9.Контракт
|
||||
#### Login-Request
|
||||
```
|
||||
{
|
||||
"login": "ivan_89",
|
||||
"password": "S3cureP@ssw0rd"
|
||||
}
|
||||
```
|
||||
##### Response - 200 - OK
|
||||
```
|
||||
{
|
||||
"token": af32df3bas739f272bd109c823
|
||||
}
|
||||
```
|
||||
|
||||
##### Errors
|
||||
* `401 BAD_CREDENTIALS` — неверный логин/пароль (B1)
|
||||
* `422 VALIDATION_FAILED` — пустые поля (B2)
|
||||
* `400 BAD_REQUEST` — сервер не смог десереализовать JSON
|
||||
|
||||
#### Logout-Request
|
||||
```
|
||||
{
|
||||
"token": af32df3bas739f272bd109c823
|
||||
}
|
||||
```
|
||||
##### Response - 200 - OK
|
||||
```
|
||||
null
|
||||
```
|
||||
|
||||
##### Errors
|
||||
* `400 BAD_REQUEST` — Такого токена не существует(B3)
|
||||
|
||||
### 10. Используемые сущности ДБ
|
||||
* users(uuid(PK), login(unique), hashed_password)
|
||||
|
||||
## UseCase №3
|
||||
### 1.Название: Переход на главную страницу
|
||||
### 2.Актор: Пользователь
|
||||
### 3.Цель: Предоставить пользователю поверхностный вывод данных о нем и инструменты для глубокого просмотра данных и их модификации
|
||||
### 4.Предусловия:
|
||||
* Пользователь имеет актуальный токен, подтверждающий его авторизацию в системе
|
||||
* Пользователь тем или иным способом перешел на главную страницу
|
||||
### 5.Основной поток:
|
||||
#### A1.Записи в дневнике есть
|
||||
* Система перенаправляет пользователя на его основную страницу
|
||||
* Система запрашивает и выводит последние записи и схемы лечения его дневника
|
||||
#### A2.Записей в дневнике нет
|
||||
* Заместо вывода записей в дневнике, система выводит заглушку, информирующую пользователя, что дневник пуст
|
||||
* Система делает доступными операции с дневником
|
||||
### 6.Потоки исключений:
|
||||
#### B1.Записи по какой-то причине не подгрузились
|
||||
* Система выводит нотификацию об ошибке и ее причине
|
||||
* Заместо вывода записей, система выводит на этом месте заглушку, информирующую о неправильной работе приложения и предоставляющей для нажатия кнопку перезагрузки страницы
|
||||
### 7.Постусловия
|
||||
* Пользователь видит свои последние записи и может по ним кликнуть, чтобы увидеть подробную информацию
|
||||
* Пользователю доступны операции добавления, модификации и удаления записей, а также схем лечения
|
||||
### 8.API-Маршруты
|
||||
* `GET /api/v1/User/Diaries` - получить кусок дневника пользователя (требует Authorization: Bearer <token>) query-параметры: from (int, по умолч. 0), count (int, по умолч. 20)
|
||||
* `GET /api/v1/User/TreatmentSchemes` - получить кусок дневника пользователя (требует Authorization: Bearer <token>) query-параметры: from (int, по умолч. 0), count (int, по умолч. 20)
|
||||
|
||||
### 9.Контракт
|
||||
#### Diaries-Request
|
||||
##### Response - 200 - OK
|
||||
```
|
||||
{
|
||||
diaries: [
|
||||
{
|
||||
"uuid": "e89b6a0c-4b0f-4722-a410-1e0c1864bf8a",
|
||||
"time": "10.08.2025",
|
||||
"mania_level": 1,
|
||||
"depression_level": 2,
|
||||
"mood_level": 3,
|
||||
"activity_level": 4,
|
||||
"appetite_level": 5,
|
||||
"dream_level": 6,
|
||||
"anxiety_level": 7,
|
||||
"treatment_scheme": {
|
||||
"uuid": "bf6d1555-39e9-4d73-8928-4763627f4dd5",
|
||||
"treatment_name": "Bipolar I Scheme",
|
||||
"instructions": "Контроль лития в крови раз в 2 месяца. Анализ крови через вену."
|
||||
"medications": [
|
||||
{
|
||||
"uuid": "8af2dfa9-3add-413c-9a0e-ff605088f1d5",
|
||||
"name": "Litii Carbonate",
|
||||
"dose": 1800,
|
||||
"unit": "mg",
|
||||
"is_urgent": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
##### Errors
|
||||
* `401 TOKEN_REQUIRED|TOKEN_EXPIRED` — токен недействителен, либо отсутствует
|
||||
* `500 DATA_LOAD_FAILED` — ошибка при загрузке данных (`B1`)
|
||||
|
||||
#### TreatmentSchemes-Request
|
||||
##### Response - 200 - OK
|
||||
```
|
||||
{
|
||||
"treatment_schemes": [
|
||||
{
|
||||
"uuid": "248313cb-a75e-4331-8379-d3f2fc36b68d"
|
||||
"treatment_name": "Bipolar I Scheme Urgent",
|
||||
"instructions": "Схема для бытрого и жесткого купирования психозов. Аминазин пить каждый день.",
|
||||
"medications": [
|
||||
{
|
||||
"uuid": "eda5a5f7-167a-44b9-900d-c5c6acfc249b",
|
||||
"name": "Aminazin",
|
||||
"dose": 100,
|
||||
"unit": "mg",
|
||||
"is_urgent": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
##### Errors
|
||||
* `401 TOKEN_REQUIRED|TOKEN_EXPIRED` — токен недействителен, либо отсутствует
|
||||
* `500 DATA_LOAD_FAILED` — ошибка при загрузке данных (B1)
|
||||
|
||||
### 10. Используемые сущности ДБ
|
||||
* diaries(uuid(PK), time , mania_level , depression_level , mood_level , activity_level , appetite_level , dream_level , anxiety_level, user_treatment_schemes_uuid)
|
||||
* mania(level(PK))
|
||||
* depressions(level(PK))
|
||||
* moods(level(PK))
|
||||
* activities(level(PK))
|
||||
* appetites(level(PK))
|
||||
* dreams(level(PK))
|
||||
* anxiety(level(PK))
|
||||
* treatment_schemes(user_treatment_schemes_uuid(PK), medication_uuid(PK))
|
||||
* user_treatment_schemes(uuid(PK), user_uuid, treatment_name, instructions)
|
||||
* medications(uuid(PK), name, dose, unit, is_urgent)
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"graph_lock": {
|
||||
"nodes": {
|
||||
"0": {
|
||||
"options": "boost:asio_no_deprecated=False\nboost:buildid=None\nboost:bzip2=True\nboost:debug_level=0\nboost:diagnostic_definitions=False\nboost:error_code_header_only=False\nboost:extra_b2_flags=None\nboost:filesystem_no_deprecated=False\nboost:filesystem_use_std_fs=False\nboost:filesystem_version=None\nboost:header_only=False\nboost:i18n_backend=deprecated\nboost:i18n_backend_iconv=off\nboost:i18n_backend_icu=False\nboost:layout=system\nboost:lzma=False\nboost:magic_autolink=False\nboost:multithreading=True\nboost:namespace=boost\nboost:namespace_alias=False\nboost:pch=True\nboost:python_executable=None\nboost:python_version=None\nboost:segmented_stacks=False\nboost:shared=False\nboost:system_no_deprecated=False\nboost:system_use_utf8=False\nboost:visibility=hidden\nboost:without_atomic=False\nboost:without_chrono=False\nboost:without_cobalt=True\nboost:without_container=False\nboost:without_context=False\nboost:without_contract=False\nboost:without_coroutine=False\nboost:without_date_time=False\nboost:without_exception=False\nboost:without_fiber=True\nboost:without_filesystem=False\nboost:without_graph=False\nboost:without_graph_parallel=True\nboost:without_iostreams=False\nboost:without_json=False\nboost:without_locale=False\nboost:without_log=False\nboost:without_math=False\nboost:without_mpi=True\nboost:without_nowide=False\nboost:without_program_options=False\nboost:without_python=True\nboost:without_random=False\nboost:without_regex=False\nboost:without_serialization=False\nboost:without_stacktrace=False\nboost:without_system=False\nboost:without_test=False\nboost:without_thread=False\nboost:without_timer=False\nboost:without_type_erasure=False\nboost:without_url=False\nboost:without_wave=False\nboost:zlib=True\nboost:zstd=False\nbzip2:build_executable=True\nbzip2:shared=False\nzlib:shared=False",
|
||||
"requires": [
|
||||
"1"
|
||||
],
|
||||
"path": "..\\conanfile.txt",
|
||||
"context": "host"
|
||||
},
|
||||
"1": {
|
||||
"ref": "boost/1.84.0",
|
||||
"options": "asio_no_deprecated=False\nbuildid=None\nbzip2=True\ndebug_level=0\ndiagnostic_definitions=False\nerror_code_header_only=False\nextra_b2_flags=None\nfilesystem_no_deprecated=False\nfilesystem_use_std_fs=False\nfilesystem_version=None\nheader_only=False\ni18n_backend=deprecated\ni18n_backend_iconv=off\ni18n_backend_icu=False\nlayout=system\nlzma=False\nmagic_autolink=False\nmultithreading=True\nnamespace=boost\nnamespace_alias=False\npch=True\npython_executable=None\npython_version=None\nsegmented_stacks=False\nshared=False\nsystem_no_deprecated=False\nsystem_use_utf8=False\nvisibility=hidden\nwithout_atomic=False\nwithout_chrono=False\nwithout_cobalt=True\nwithout_container=False\nwithout_context=False\nwithout_contract=False\nwithout_coroutine=False\nwithout_date_time=False\nwithout_exception=False\nwithout_fiber=True\nwithout_filesystem=False\nwithout_graph=False\nwithout_graph_parallel=True\nwithout_iostreams=False\nwithout_json=False\nwithout_locale=False\nwithout_log=False\nwithout_math=False\nwithout_mpi=True\nwithout_nowide=False\nwithout_program_options=False\nwithout_python=True\nwithout_random=False\nwithout_regex=False\nwithout_serialization=False\nwithout_stacktrace=False\nwithout_system=False\nwithout_test=False\nwithout_thread=False\nwithout_timer=False\nwithout_type_erasure=False\nwithout_url=False\nwithout_wave=False\nzlib=True\nzstd=False\nbzip2:build_executable=True\nbzip2:shared=False\nzlib:shared=False",
|
||||
"package_id": "e50863e182b9f1a9ce9e711c031065f1fe5f7f78",
|
||||
"prev": "0",
|
||||
"requires": [
|
||||
"2",
|
||||
"3"
|
||||
],
|
||||
"context": "host"
|
||||
},
|
||||
"2": {
|
||||
"ref": "zlib/1.3.1",
|
||||
"options": "shared=False",
|
||||
"package_id": "5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b",
|
||||
"prev": "0",
|
||||
"context": "host"
|
||||
},
|
||||
"3": {
|
||||
"ref": "bzip2/1.0.8",
|
||||
"options": "build_executable=True\nshared=False",
|
||||
"package_id": "53b5fd22ba061620078deefdae9a437c5f693201",
|
||||
"prev": "0",
|
||||
"context": "host"
|
||||
}
|
||||
},
|
||||
"revisions_enabled": false
|
||||
},
|
||||
"version": "0.4",
|
||||
"profile_host": "[settings]\narch=x86_64\narch_build=x86_64\nbuild_type=Release\ncompiler=Visual Studio\ncompiler.runtime=MD\ncompiler.version=17\nos=Windows\nos_build=Windows\n[options]\n[build_requires]\n[env]\n"
|
||||
}
|
||||
@@ -1,1020 +0,0 @@
|
||||
include(CMakeParseArguments)
|
||||
|
||||
macro(conan_find_apple_frameworks FRAMEWORKS_FOUND FRAMEWORKS SUFFIX BUILD_TYPE)
|
||||
if(APPLE)
|
||||
if(CMAKE_BUILD_TYPE)
|
||||
set(_BTYPE ${CMAKE_BUILD_TYPE})
|
||||
elseif(NOT BUILD_TYPE STREQUAL "")
|
||||
set(_BTYPE ${BUILD_TYPE})
|
||||
endif()
|
||||
if(_BTYPE)
|
||||
if(${_BTYPE} MATCHES "Debug|_DEBUG")
|
||||
set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORKS${SUFFIX}})
|
||||
set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_DEBUG} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
|
||||
elseif(${_BTYPE} MATCHES "Release|_RELEASE")
|
||||
set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_RELEASE} ${CONAN_FRAMEWORKS${SUFFIX}})
|
||||
set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_RELEASE} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
|
||||
elseif(${_BTYPE} MATCHES "RelWithDebInfo|_RELWITHDEBINFO")
|
||||
set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_RELWITHDEBINFO} ${CONAN_FRAMEWORKS${SUFFIX}})
|
||||
set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_RELWITHDEBINFO} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
|
||||
elseif(${_BTYPE} MATCHES "MinSizeRel|_MINSIZEREL")
|
||||
set(CONAN_FRAMEWORKS${SUFFIX} ${CONAN_FRAMEWORKS${SUFFIX}_MINSIZEREL} ${CONAN_FRAMEWORKS${SUFFIX}})
|
||||
set(CONAN_FRAMEWORK_DIRS${SUFFIX} ${CONAN_FRAMEWORK_DIRS${SUFFIX}_MINSIZEREL} ${CONAN_FRAMEWORK_DIRS${SUFFIX}})
|
||||
endif()
|
||||
endif()
|
||||
foreach(_FRAMEWORK ${FRAMEWORKS})
|
||||
# https://cmake.org/pipermail/cmake-developers/2017-August/030199.html
|
||||
find_library(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND NAMES ${_FRAMEWORK} PATHS ${CONAN_FRAMEWORK_DIRS${SUFFIX}} CMAKE_FIND_ROOT_PATH_BOTH)
|
||||
if(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND)
|
||||
list(APPEND ${FRAMEWORKS_FOUND} ${CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND})
|
||||
else()
|
||||
message(FATAL_ERROR "Framework library ${_FRAMEWORK} not found in paths: ${CONAN_FRAMEWORK_DIRS${SUFFIX}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
#################
|
||||
### BOOST
|
||||
#################
|
||||
set(CONAN_BOOST_ROOT "C:/.conan/029ec3/1")
|
||||
set(CONAN_INCLUDE_DIRS_BOOST "C:/.conan/029ec3/1/include")
|
||||
set(CONAN_LIB_DIRS_BOOST "C:/.conan/029ec3/1/lib")
|
||||
set(CONAN_BIN_DIRS_BOOST )
|
||||
set(CONAN_RES_DIRS_BOOST )
|
||||
set(CONAN_SRC_DIRS_BOOST )
|
||||
set(CONAN_BUILD_DIRS_BOOST )
|
||||
set(CONAN_FRAMEWORK_DIRS_BOOST )
|
||||
set(CONAN_LIBS_BOOST libboost_contract libboost_coroutine libboost_context libboost_graph libboost_iostreams libboost_json libboost_locale libboost_log_setup libboost_log libboost_math_c99 libboost_math_c99f libboost_math_c99l libboost_math_tr1 libboost_math_tr1f libboost_math_tr1l libboost_nowide libboost_program_options libboost_random libboost_regex libboost_stacktrace_noop libboost_stacktrace_windbg libboost_stacktrace_windbg_cached libboost_timer libboost_type_erasure libboost_thread libboost_chrono libboost_container libboost_date_time libboost_unit_test_framework libboost_prg_exec_monitor libboost_test_exec_monitor libboost_exception libboost_url libboost_wave libboost_filesystem libboost_atomic libboost_wserialization libboost_serialization)
|
||||
set(CONAN_PKG_LIBS_BOOST libboost_contract libboost_coroutine libboost_context libboost_graph libboost_iostreams libboost_json libboost_locale libboost_log_setup libboost_log libboost_math_c99 libboost_math_c99f libboost_math_c99l libboost_math_tr1 libboost_math_tr1f libboost_math_tr1l libboost_nowide libboost_program_options libboost_random libboost_regex libboost_stacktrace_noop libboost_stacktrace_windbg libboost_stacktrace_windbg_cached libboost_timer libboost_type_erasure libboost_thread libboost_chrono libboost_container libboost_date_time libboost_unit_test_framework libboost_prg_exec_monitor libboost_test_exec_monitor libboost_exception libboost_url libboost_wave libboost_filesystem libboost_atomic libboost_wserialization libboost_serialization)
|
||||
set(CONAN_SYSTEM_LIBS_BOOST ole32 dbgeng bcrypt ntdll shell32 Advapi32 user32)
|
||||
set(CONAN_FRAMEWORKS_BOOST )
|
||||
set(CONAN_FRAMEWORKS_FOUND_BOOST "") # Will be filled later
|
||||
set(CONAN_DEFINES_BOOST "-DBOOST_STACKTRACE_USE_NOOP"
|
||||
"-DBOOST_STACKTRACE_USE_WINDBG"
|
||||
"-DBOOST_STACKTRACE_USE_WINDBG_CACHED"
|
||||
"-DBOOST_ALL_NO_LIB")
|
||||
set(CONAN_BUILD_MODULES_PATHS_BOOST )
|
||||
# COMPILE_DEFINITIONS are equal to CONAN_DEFINES without -D, for targets
|
||||
set(CONAN_COMPILE_DEFINITIONS_BOOST "BOOST_STACKTRACE_USE_NOOP"
|
||||
"BOOST_STACKTRACE_USE_WINDBG"
|
||||
"BOOST_STACKTRACE_USE_WINDBG_CACHED"
|
||||
"BOOST_ALL_NO_LIB")
|
||||
|
||||
set(CONAN_C_FLAGS_BOOST "")
|
||||
set(CONAN_CXX_FLAGS_BOOST "")
|
||||
set(CONAN_SHARED_LINKER_FLAGS_BOOST "")
|
||||
set(CONAN_EXE_LINKER_FLAGS_BOOST "")
|
||||
|
||||
# For modern cmake targets we use the list variables (separated with ;)
|
||||
set(CONAN_C_FLAGS_BOOST_LIST "")
|
||||
set(CONAN_CXX_FLAGS_BOOST_LIST "")
|
||||
set(CONAN_SHARED_LINKER_FLAGS_BOOST_LIST "")
|
||||
set(CONAN_EXE_LINKER_FLAGS_BOOST_LIST "")
|
||||
|
||||
# Apple Frameworks
|
||||
conan_find_apple_frameworks(CONAN_FRAMEWORKS_FOUND_BOOST "${CONAN_FRAMEWORKS_BOOST}" "_BOOST" "")
|
||||
# Append to aggregated values variable
|
||||
set(CONAN_LIBS_BOOST ${CONAN_PKG_LIBS_BOOST} ${CONAN_SYSTEM_LIBS_BOOST} ${CONAN_FRAMEWORKS_FOUND_BOOST})
|
||||
|
||||
|
||||
#################
|
||||
### ZLIB
|
||||
#################
|
||||
set(CONAN_ZLIB_ROOT "C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b")
|
||||
set(CONAN_INCLUDE_DIRS_ZLIB "C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/include")
|
||||
set(CONAN_LIB_DIRS_ZLIB "C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/lib")
|
||||
set(CONAN_BIN_DIRS_ZLIB )
|
||||
set(CONAN_RES_DIRS_ZLIB )
|
||||
set(CONAN_SRC_DIRS_ZLIB )
|
||||
set(CONAN_BUILD_DIRS_ZLIB "C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/")
|
||||
set(CONAN_FRAMEWORK_DIRS_ZLIB )
|
||||
set(CONAN_LIBS_ZLIB zlib)
|
||||
set(CONAN_PKG_LIBS_ZLIB zlib)
|
||||
set(CONAN_SYSTEM_LIBS_ZLIB )
|
||||
set(CONAN_FRAMEWORKS_ZLIB )
|
||||
set(CONAN_FRAMEWORKS_FOUND_ZLIB "") # Will be filled later
|
||||
set(CONAN_DEFINES_ZLIB )
|
||||
set(CONAN_BUILD_MODULES_PATHS_ZLIB )
|
||||
# COMPILE_DEFINITIONS are equal to CONAN_DEFINES without -D, for targets
|
||||
set(CONAN_COMPILE_DEFINITIONS_ZLIB )
|
||||
|
||||
set(CONAN_C_FLAGS_ZLIB "")
|
||||
set(CONAN_CXX_FLAGS_ZLIB "")
|
||||
set(CONAN_SHARED_LINKER_FLAGS_ZLIB "")
|
||||
set(CONAN_EXE_LINKER_FLAGS_ZLIB "")
|
||||
|
||||
# For modern cmake targets we use the list variables (separated with ;)
|
||||
set(CONAN_C_FLAGS_ZLIB_LIST "")
|
||||
set(CONAN_CXX_FLAGS_ZLIB_LIST "")
|
||||
set(CONAN_SHARED_LINKER_FLAGS_ZLIB_LIST "")
|
||||
set(CONAN_EXE_LINKER_FLAGS_ZLIB_LIST "")
|
||||
|
||||
# Apple Frameworks
|
||||
conan_find_apple_frameworks(CONAN_FRAMEWORKS_FOUND_ZLIB "${CONAN_FRAMEWORKS_ZLIB}" "_ZLIB" "")
|
||||
# Append to aggregated values variable
|
||||
set(CONAN_LIBS_ZLIB ${CONAN_PKG_LIBS_ZLIB} ${CONAN_SYSTEM_LIBS_ZLIB} ${CONAN_FRAMEWORKS_FOUND_ZLIB})
|
||||
|
||||
|
||||
#################
|
||||
### BZIP2
|
||||
#################
|
||||
set(CONAN_BZIP2_ROOT "C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201")
|
||||
set(CONAN_INCLUDE_DIRS_BZIP2 "C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/include")
|
||||
set(CONAN_LIB_DIRS_BZIP2 "C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/lib")
|
||||
set(CONAN_BIN_DIRS_BZIP2 "C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/bin")
|
||||
set(CONAN_RES_DIRS_BZIP2 )
|
||||
set(CONAN_SRC_DIRS_BZIP2 )
|
||||
set(CONAN_BUILD_DIRS_BZIP2 "C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/")
|
||||
set(CONAN_FRAMEWORK_DIRS_BZIP2 )
|
||||
set(CONAN_LIBS_BZIP2 bz2)
|
||||
set(CONAN_PKG_LIBS_BZIP2 bz2)
|
||||
set(CONAN_SYSTEM_LIBS_BZIP2 )
|
||||
set(CONAN_FRAMEWORKS_BZIP2 )
|
||||
set(CONAN_FRAMEWORKS_FOUND_BZIP2 "") # Will be filled later
|
||||
set(CONAN_DEFINES_BZIP2 )
|
||||
set(CONAN_BUILD_MODULES_PATHS_BZIP2 )
|
||||
# COMPILE_DEFINITIONS are equal to CONAN_DEFINES without -D, for targets
|
||||
set(CONAN_COMPILE_DEFINITIONS_BZIP2 )
|
||||
|
||||
set(CONAN_C_FLAGS_BZIP2 "")
|
||||
set(CONAN_CXX_FLAGS_BZIP2 "")
|
||||
set(CONAN_SHARED_LINKER_FLAGS_BZIP2 "")
|
||||
set(CONAN_EXE_LINKER_FLAGS_BZIP2 "")
|
||||
|
||||
# For modern cmake targets we use the list variables (separated with ;)
|
||||
set(CONAN_C_FLAGS_BZIP2_LIST "")
|
||||
set(CONAN_CXX_FLAGS_BZIP2_LIST "")
|
||||
set(CONAN_SHARED_LINKER_FLAGS_BZIP2_LIST "")
|
||||
set(CONAN_EXE_LINKER_FLAGS_BZIP2_LIST "")
|
||||
|
||||
# Apple Frameworks
|
||||
conan_find_apple_frameworks(CONAN_FRAMEWORKS_FOUND_BZIP2 "${CONAN_FRAMEWORKS_BZIP2}" "_BZIP2" "")
|
||||
# Append to aggregated values variable
|
||||
set(CONAN_LIBS_BZIP2 ${CONAN_PKG_LIBS_BZIP2} ${CONAN_SYSTEM_LIBS_BZIP2} ${CONAN_FRAMEWORKS_FOUND_BZIP2})
|
||||
|
||||
|
||||
### Definition of global aggregated variables ###
|
||||
|
||||
set(CONAN_PACKAGE_NAME None)
|
||||
set(CONAN_PACKAGE_VERSION None)
|
||||
|
||||
set(CONAN_SETTINGS_ARCH "x86_64")
|
||||
set(CONAN_SETTINGS_ARCH_BUILD "x86_64")
|
||||
set(CONAN_SETTINGS_BUILD_TYPE "Release")
|
||||
set(CONAN_SETTINGS_COMPILER "Visual Studio")
|
||||
set(CONAN_SETTINGS_COMPILER_RUNTIME "MD")
|
||||
set(CONAN_SETTINGS_COMPILER_VERSION "17")
|
||||
set(CONAN_SETTINGS_OS "Windows")
|
||||
set(CONAN_SETTINGS_OS_BUILD "Windows")
|
||||
|
||||
set(CONAN_DEPENDENCIES boost zlib bzip2)
|
||||
# Storing original command line args (CMake helper) flags
|
||||
set(CONAN_CMD_CXX_FLAGS ${CONAN_CXX_FLAGS})
|
||||
|
||||
set(CONAN_CMD_SHARED_LINKER_FLAGS ${CONAN_SHARED_LINKER_FLAGS})
|
||||
set(CONAN_CMD_C_FLAGS ${CONAN_C_FLAGS})
|
||||
# Defining accumulated conan variables for all deps
|
||||
|
||||
set(CONAN_INCLUDE_DIRS "C:/.conan/029ec3/1/include"
|
||||
"C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/include"
|
||||
"C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/include" ${CONAN_INCLUDE_DIRS})
|
||||
set(CONAN_LIB_DIRS "C:/.conan/029ec3/1/lib"
|
||||
"C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/lib"
|
||||
"C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/lib" ${CONAN_LIB_DIRS})
|
||||
set(CONAN_BIN_DIRS "C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/bin" ${CONAN_BIN_DIRS})
|
||||
set(CONAN_RES_DIRS ${CONAN_RES_DIRS})
|
||||
set(CONAN_FRAMEWORK_DIRS ${CONAN_FRAMEWORK_DIRS})
|
||||
set(CONAN_LIBS libboost_contract libboost_coroutine libboost_context libboost_graph libboost_iostreams libboost_json libboost_locale libboost_log_setup libboost_log libboost_math_c99 libboost_math_c99f libboost_math_c99l libboost_math_tr1 libboost_math_tr1f libboost_math_tr1l libboost_nowide libboost_program_options libboost_random libboost_regex libboost_stacktrace_noop libboost_stacktrace_windbg libboost_stacktrace_windbg_cached libboost_timer libboost_type_erasure libboost_thread libboost_chrono libboost_container libboost_date_time libboost_unit_test_framework libboost_prg_exec_monitor libboost_test_exec_monitor libboost_exception libboost_url libboost_wave libboost_filesystem libboost_atomic libboost_wserialization libboost_serialization zlib bz2 ${CONAN_LIBS})
|
||||
set(CONAN_PKG_LIBS libboost_contract libboost_coroutine libboost_context libboost_graph libboost_iostreams libboost_json libboost_locale libboost_log_setup libboost_log libboost_math_c99 libboost_math_c99f libboost_math_c99l libboost_math_tr1 libboost_math_tr1f libboost_math_tr1l libboost_nowide libboost_program_options libboost_random libboost_regex libboost_stacktrace_noop libboost_stacktrace_windbg libboost_stacktrace_windbg_cached libboost_timer libboost_type_erasure libboost_thread libboost_chrono libboost_container libboost_date_time libboost_unit_test_framework libboost_prg_exec_monitor libboost_test_exec_monitor libboost_exception libboost_url libboost_wave libboost_filesystem libboost_atomic libboost_wserialization libboost_serialization zlib bz2 ${CONAN_PKG_LIBS})
|
||||
set(CONAN_SYSTEM_LIBS ole32 dbgeng bcrypt ntdll shell32 Advapi32 user32 ${CONAN_SYSTEM_LIBS})
|
||||
set(CONAN_FRAMEWORKS ${CONAN_FRAMEWORKS})
|
||||
set(CONAN_FRAMEWORKS_FOUND "") # Will be filled later
|
||||
set(CONAN_DEFINES "-DBOOST_STACKTRACE_USE_NOOP"
|
||||
"-DBOOST_STACKTRACE_USE_WINDBG"
|
||||
"-DBOOST_STACKTRACE_USE_WINDBG_CACHED"
|
||||
"-DBOOST_ALL_NO_LIB" ${CONAN_DEFINES})
|
||||
set(CONAN_BUILD_MODULES_PATHS ${CONAN_BUILD_MODULES_PATHS})
|
||||
set(CONAN_CMAKE_MODULE_PATH "C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/"
|
||||
"C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/" ${CONAN_CMAKE_MODULE_PATH})
|
||||
|
||||
set(CONAN_CXX_FLAGS " ${CONAN_CXX_FLAGS}")
|
||||
set(CONAN_SHARED_LINKER_FLAGS " ${CONAN_SHARED_LINKER_FLAGS}")
|
||||
set(CONAN_EXE_LINKER_FLAGS " ${CONAN_EXE_LINKER_FLAGS}")
|
||||
set(CONAN_C_FLAGS " ${CONAN_C_FLAGS}")
|
||||
|
||||
# Apple Frameworks
|
||||
conan_find_apple_frameworks(CONAN_FRAMEWORKS_FOUND "${CONAN_FRAMEWORKS}" "" "")
|
||||
# Append to aggregated values variable: Use CONAN_LIBS instead of CONAN_PKG_LIBS to include user appended vars
|
||||
set(CONAN_LIBS ${CONAN_LIBS} ${CONAN_SYSTEM_LIBS} ${CONAN_FRAMEWORKS_FOUND})
|
||||
|
||||
|
||||
### Definition of macros and functions ###
|
||||
|
||||
macro(conan_define_targets)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.1.2")
|
||||
message(FATAL_ERROR "TARGETS not supported by your CMake version!")
|
||||
endif() # CMAKE > 3.x
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CONAN_CMD_CXX_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CONAN_CMD_C_FLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CONAN_CMD_SHARED_LINKER_FLAGS}")
|
||||
|
||||
|
||||
set(_CONAN_PKG_LIBS_BOOST_DEPENDENCIES "${CONAN_SYSTEM_LIBS_BOOST} ${CONAN_FRAMEWORKS_FOUND_BOOST} CONAN_PKG::zlib CONAN_PKG::bzip2")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BOOST_DEPENDENCIES "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BOOST}" "${CONAN_LIB_DIRS_BOOST}"
|
||||
CONAN_PACKAGE_TARGETS_BOOST "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES}"
|
||||
"" boost)
|
||||
set(_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_DEBUG "${CONAN_SYSTEM_LIBS_BOOST_DEBUG} ${CONAN_FRAMEWORKS_FOUND_BOOST_DEBUG} CONAN_PKG::zlib CONAN_PKG::bzip2")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BOOST_DEPENDENCIES_DEBUG "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_DEBUG}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BOOST_DEBUG}" "${CONAN_LIB_DIRS_BOOST_DEBUG}"
|
||||
CONAN_PACKAGE_TARGETS_BOOST_DEBUG "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_DEBUG}"
|
||||
"debug" boost)
|
||||
set(_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELEASE "${CONAN_SYSTEM_LIBS_BOOST_RELEASE} ${CONAN_FRAMEWORKS_FOUND_BOOST_RELEASE} CONAN_PKG::zlib CONAN_PKG::bzip2")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELEASE "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELEASE}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BOOST_RELEASE}" "${CONAN_LIB_DIRS_BOOST_RELEASE}"
|
||||
CONAN_PACKAGE_TARGETS_BOOST_RELEASE "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELEASE}"
|
||||
"release" boost)
|
||||
set(_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELWITHDEBINFO "${CONAN_SYSTEM_LIBS_BOOST_RELWITHDEBINFO} ${CONAN_FRAMEWORKS_FOUND_BOOST_RELWITHDEBINFO} CONAN_PKG::zlib CONAN_PKG::bzip2")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELWITHDEBINFO "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELWITHDEBINFO}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BOOST_RELWITHDEBINFO}" "${CONAN_LIB_DIRS_BOOST_RELWITHDEBINFO}"
|
||||
CONAN_PACKAGE_TARGETS_BOOST_RELWITHDEBINFO "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELWITHDEBINFO}"
|
||||
"relwithdebinfo" boost)
|
||||
set(_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_MINSIZEREL "${CONAN_SYSTEM_LIBS_BOOST_MINSIZEREL} ${CONAN_FRAMEWORKS_FOUND_BOOST_MINSIZEREL} CONAN_PKG::zlib CONAN_PKG::bzip2")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BOOST_DEPENDENCIES_MINSIZEREL "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_MINSIZEREL}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BOOST_MINSIZEREL}" "${CONAN_LIB_DIRS_BOOST_MINSIZEREL}"
|
||||
CONAN_PACKAGE_TARGETS_BOOST_MINSIZEREL "${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_MINSIZEREL}"
|
||||
"minsizerel" boost)
|
||||
|
||||
add_library(CONAN_PKG::boost INTERFACE IMPORTED)
|
||||
|
||||
# Property INTERFACE_LINK_FLAGS do not work, necessary to add to INTERFACE_LINK_LIBRARIES
|
||||
set_property(TARGET CONAN_PKG::boost PROPERTY INTERFACE_LINK_LIBRARIES ${CONAN_PACKAGE_TARGETS_BOOST} ${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BOOST_LIST}>
|
||||
|
||||
$<$<CONFIG:Release>:${CONAN_PACKAGE_TARGETS_BOOST_RELEASE} ${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELEASE}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_RELEASE_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_RELEASE_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BOOST_RELEASE_LIST}>>
|
||||
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_PACKAGE_TARGETS_BOOST_RELWITHDEBINFO} ${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_RELWITHDEBINFO}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_RELWITHDEBINFO_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_RELWITHDEBINFO_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BOOST_RELWITHDEBINFO_LIST}>>
|
||||
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_PACKAGE_TARGETS_BOOST_MINSIZEREL} ${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_MINSIZEREL}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_MINSIZEREL_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_MINSIZEREL_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BOOST_MINSIZEREL_LIST}>>
|
||||
|
||||
$<$<CONFIG:Debug>:${CONAN_PACKAGE_TARGETS_BOOST_DEBUG} ${_CONAN_PKG_LIBS_BOOST_DEPENDENCIES_DEBUG}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_DEBUG_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BOOST_DEBUG_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BOOST_DEBUG_LIST}>>)
|
||||
set_property(TARGET CONAN_PKG::boost PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CONAN_INCLUDE_DIRS_BOOST}
|
||||
$<$<CONFIG:Release>:${CONAN_INCLUDE_DIRS_BOOST_RELEASE}>
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_INCLUDE_DIRS_BOOST_RELWITHDEBINFO}>
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_INCLUDE_DIRS_BOOST_MINSIZEREL}>
|
||||
$<$<CONFIG:Debug>:${CONAN_INCLUDE_DIRS_BOOST_DEBUG}>)
|
||||
set_property(TARGET CONAN_PKG::boost PROPERTY INTERFACE_COMPILE_DEFINITIONS ${CONAN_COMPILE_DEFINITIONS_BOOST}
|
||||
$<$<CONFIG:Release>:${CONAN_COMPILE_DEFINITIONS_BOOST_RELEASE}>
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_COMPILE_DEFINITIONS_BOOST_RELWITHDEBINFO}>
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_COMPILE_DEFINITIONS_BOOST_MINSIZEREL}>
|
||||
$<$<CONFIG:Debug>:${CONAN_COMPILE_DEFINITIONS_BOOST_DEBUG}>)
|
||||
set_property(TARGET CONAN_PKG::boost PROPERTY INTERFACE_COMPILE_OPTIONS ${CONAN_C_FLAGS_BOOST_LIST} ${CONAN_CXX_FLAGS_BOOST_LIST}
|
||||
$<$<CONFIG:Release>:${CONAN_C_FLAGS_BOOST_RELEASE_LIST} ${CONAN_CXX_FLAGS_BOOST_RELEASE_LIST}>
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_C_FLAGS_BOOST_RELWITHDEBINFO_LIST} ${CONAN_CXX_FLAGS_BOOST_RELWITHDEBINFO_LIST}>
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_C_FLAGS_BOOST_MINSIZEREL_LIST} ${CONAN_CXX_FLAGS_BOOST_MINSIZEREL_LIST}>
|
||||
$<$<CONFIG:Debug>:${CONAN_C_FLAGS_BOOST_DEBUG_LIST} ${CONAN_CXX_FLAGS_BOOST_DEBUG_LIST}>)
|
||||
|
||||
|
||||
set(_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES "${CONAN_SYSTEM_LIBS_ZLIB} ${CONAN_FRAMEWORKS_FOUND_ZLIB} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_ZLIB_DEPENDENCIES "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_ZLIB}" "${CONAN_LIB_DIRS_ZLIB}"
|
||||
CONAN_PACKAGE_TARGETS_ZLIB "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES}"
|
||||
"" zlib)
|
||||
set(_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_DEBUG "${CONAN_SYSTEM_LIBS_ZLIB_DEBUG} ${CONAN_FRAMEWORKS_FOUND_ZLIB_DEBUG} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_DEBUG "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_DEBUG}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_ZLIB_DEBUG}" "${CONAN_LIB_DIRS_ZLIB_DEBUG}"
|
||||
CONAN_PACKAGE_TARGETS_ZLIB_DEBUG "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_DEBUG}"
|
||||
"debug" zlib)
|
||||
set(_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELEASE "${CONAN_SYSTEM_LIBS_ZLIB_RELEASE} ${CONAN_FRAMEWORKS_FOUND_ZLIB_RELEASE} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELEASE "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELEASE}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_ZLIB_RELEASE}" "${CONAN_LIB_DIRS_ZLIB_RELEASE}"
|
||||
CONAN_PACKAGE_TARGETS_ZLIB_RELEASE "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELEASE}"
|
||||
"release" zlib)
|
||||
set(_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELWITHDEBINFO "${CONAN_SYSTEM_LIBS_ZLIB_RELWITHDEBINFO} ${CONAN_FRAMEWORKS_FOUND_ZLIB_RELWITHDEBINFO} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELWITHDEBINFO "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELWITHDEBINFO}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_ZLIB_RELWITHDEBINFO}" "${CONAN_LIB_DIRS_ZLIB_RELWITHDEBINFO}"
|
||||
CONAN_PACKAGE_TARGETS_ZLIB_RELWITHDEBINFO "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELWITHDEBINFO}"
|
||||
"relwithdebinfo" zlib)
|
||||
set(_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_MINSIZEREL "${CONAN_SYSTEM_LIBS_ZLIB_MINSIZEREL} ${CONAN_FRAMEWORKS_FOUND_ZLIB_MINSIZEREL} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_MINSIZEREL "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_MINSIZEREL}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_ZLIB_MINSIZEREL}" "${CONAN_LIB_DIRS_ZLIB_MINSIZEREL}"
|
||||
CONAN_PACKAGE_TARGETS_ZLIB_MINSIZEREL "${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_MINSIZEREL}"
|
||||
"minsizerel" zlib)
|
||||
|
||||
add_library(CONAN_PKG::zlib INTERFACE IMPORTED)
|
||||
|
||||
# Property INTERFACE_LINK_FLAGS do not work, necessary to add to INTERFACE_LINK_LIBRARIES
|
||||
set_property(TARGET CONAN_PKG::zlib PROPERTY INTERFACE_LINK_LIBRARIES ${CONAN_PACKAGE_TARGETS_ZLIB} ${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_ZLIB_LIST}>
|
||||
|
||||
$<$<CONFIG:Release>:${CONAN_PACKAGE_TARGETS_ZLIB_RELEASE} ${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELEASE}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_RELEASE_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_RELEASE_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_ZLIB_RELEASE_LIST}>>
|
||||
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_PACKAGE_TARGETS_ZLIB_RELWITHDEBINFO} ${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_RELWITHDEBINFO}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_RELWITHDEBINFO_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_RELWITHDEBINFO_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_ZLIB_RELWITHDEBINFO_LIST}>>
|
||||
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_PACKAGE_TARGETS_ZLIB_MINSIZEREL} ${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_MINSIZEREL}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_MINSIZEREL_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_MINSIZEREL_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_ZLIB_MINSIZEREL_LIST}>>
|
||||
|
||||
$<$<CONFIG:Debug>:${CONAN_PACKAGE_TARGETS_ZLIB_DEBUG} ${_CONAN_PKG_LIBS_ZLIB_DEPENDENCIES_DEBUG}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_DEBUG_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_ZLIB_DEBUG_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_ZLIB_DEBUG_LIST}>>)
|
||||
set_property(TARGET CONAN_PKG::zlib PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CONAN_INCLUDE_DIRS_ZLIB}
|
||||
$<$<CONFIG:Release>:${CONAN_INCLUDE_DIRS_ZLIB_RELEASE}>
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_INCLUDE_DIRS_ZLIB_RELWITHDEBINFO}>
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_INCLUDE_DIRS_ZLIB_MINSIZEREL}>
|
||||
$<$<CONFIG:Debug>:${CONAN_INCLUDE_DIRS_ZLIB_DEBUG}>)
|
||||
set_property(TARGET CONAN_PKG::zlib PROPERTY INTERFACE_COMPILE_DEFINITIONS ${CONAN_COMPILE_DEFINITIONS_ZLIB}
|
||||
$<$<CONFIG:Release>:${CONAN_COMPILE_DEFINITIONS_ZLIB_RELEASE}>
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_COMPILE_DEFINITIONS_ZLIB_RELWITHDEBINFO}>
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_COMPILE_DEFINITIONS_ZLIB_MINSIZEREL}>
|
||||
$<$<CONFIG:Debug>:${CONAN_COMPILE_DEFINITIONS_ZLIB_DEBUG}>)
|
||||
set_property(TARGET CONAN_PKG::zlib PROPERTY INTERFACE_COMPILE_OPTIONS ${CONAN_C_FLAGS_ZLIB_LIST} ${CONAN_CXX_FLAGS_ZLIB_LIST}
|
||||
$<$<CONFIG:Release>:${CONAN_C_FLAGS_ZLIB_RELEASE_LIST} ${CONAN_CXX_FLAGS_ZLIB_RELEASE_LIST}>
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_C_FLAGS_ZLIB_RELWITHDEBINFO_LIST} ${CONAN_CXX_FLAGS_ZLIB_RELWITHDEBINFO_LIST}>
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_C_FLAGS_ZLIB_MINSIZEREL_LIST} ${CONAN_CXX_FLAGS_ZLIB_MINSIZEREL_LIST}>
|
||||
$<$<CONFIG:Debug>:${CONAN_C_FLAGS_ZLIB_DEBUG_LIST} ${CONAN_CXX_FLAGS_ZLIB_DEBUG_LIST}>)
|
||||
|
||||
|
||||
set(_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES "${CONAN_SYSTEM_LIBS_BZIP2} ${CONAN_FRAMEWORKS_FOUND_BZIP2} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BZIP2_DEPENDENCIES "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BZIP2}" "${CONAN_LIB_DIRS_BZIP2}"
|
||||
CONAN_PACKAGE_TARGETS_BZIP2 "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES}"
|
||||
"" bzip2)
|
||||
set(_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_DEBUG "${CONAN_SYSTEM_LIBS_BZIP2_DEBUG} ${CONAN_FRAMEWORKS_FOUND_BZIP2_DEBUG} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_DEBUG "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_DEBUG}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BZIP2_DEBUG}" "${CONAN_LIB_DIRS_BZIP2_DEBUG}"
|
||||
CONAN_PACKAGE_TARGETS_BZIP2_DEBUG "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_DEBUG}"
|
||||
"debug" bzip2)
|
||||
set(_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELEASE "${CONAN_SYSTEM_LIBS_BZIP2_RELEASE} ${CONAN_FRAMEWORKS_FOUND_BZIP2_RELEASE} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELEASE "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELEASE}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BZIP2_RELEASE}" "${CONAN_LIB_DIRS_BZIP2_RELEASE}"
|
||||
CONAN_PACKAGE_TARGETS_BZIP2_RELEASE "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELEASE}"
|
||||
"release" bzip2)
|
||||
set(_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELWITHDEBINFO "${CONAN_SYSTEM_LIBS_BZIP2_RELWITHDEBINFO} ${CONAN_FRAMEWORKS_FOUND_BZIP2_RELWITHDEBINFO} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELWITHDEBINFO "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELWITHDEBINFO}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BZIP2_RELWITHDEBINFO}" "${CONAN_LIB_DIRS_BZIP2_RELWITHDEBINFO}"
|
||||
CONAN_PACKAGE_TARGETS_BZIP2_RELWITHDEBINFO "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELWITHDEBINFO}"
|
||||
"relwithdebinfo" bzip2)
|
||||
set(_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_MINSIZEREL "${CONAN_SYSTEM_LIBS_BZIP2_MINSIZEREL} ${CONAN_FRAMEWORKS_FOUND_BZIP2_MINSIZEREL} ")
|
||||
string(REPLACE " " ";" _CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_MINSIZEREL "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_MINSIZEREL}")
|
||||
conan_package_library_targets("${CONAN_PKG_LIBS_BZIP2_MINSIZEREL}" "${CONAN_LIB_DIRS_BZIP2_MINSIZEREL}"
|
||||
CONAN_PACKAGE_TARGETS_BZIP2_MINSIZEREL "${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_MINSIZEREL}"
|
||||
"minsizerel" bzip2)
|
||||
|
||||
add_library(CONAN_PKG::bzip2 INTERFACE IMPORTED)
|
||||
|
||||
# Property INTERFACE_LINK_FLAGS do not work, necessary to add to INTERFACE_LINK_LIBRARIES
|
||||
set_property(TARGET CONAN_PKG::bzip2 PROPERTY INTERFACE_LINK_LIBRARIES ${CONAN_PACKAGE_TARGETS_BZIP2} ${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BZIP2_LIST}>
|
||||
|
||||
$<$<CONFIG:Release>:${CONAN_PACKAGE_TARGETS_BZIP2_RELEASE} ${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELEASE}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_RELEASE_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_RELEASE_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BZIP2_RELEASE_LIST}>>
|
||||
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_PACKAGE_TARGETS_BZIP2_RELWITHDEBINFO} ${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_RELWITHDEBINFO}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_RELWITHDEBINFO_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_RELWITHDEBINFO_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BZIP2_RELWITHDEBINFO_LIST}>>
|
||||
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_PACKAGE_TARGETS_BZIP2_MINSIZEREL} ${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_MINSIZEREL}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_MINSIZEREL_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_MINSIZEREL_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BZIP2_MINSIZEREL_LIST}>>
|
||||
|
||||
$<$<CONFIG:Debug>:${CONAN_PACKAGE_TARGETS_BZIP2_DEBUG} ${_CONAN_PKG_LIBS_BZIP2_DEPENDENCIES_DEBUG}
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_DEBUG_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:${CONAN_SHARED_LINKER_FLAGS_BZIP2_DEBUG_LIST}>
|
||||
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:${CONAN_EXE_LINKER_FLAGS_BZIP2_DEBUG_LIST}>>)
|
||||
set_property(TARGET CONAN_PKG::bzip2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CONAN_INCLUDE_DIRS_BZIP2}
|
||||
$<$<CONFIG:Release>:${CONAN_INCLUDE_DIRS_BZIP2_RELEASE}>
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_INCLUDE_DIRS_BZIP2_RELWITHDEBINFO}>
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_INCLUDE_DIRS_BZIP2_MINSIZEREL}>
|
||||
$<$<CONFIG:Debug>:${CONAN_INCLUDE_DIRS_BZIP2_DEBUG}>)
|
||||
set_property(TARGET CONAN_PKG::bzip2 PROPERTY INTERFACE_COMPILE_DEFINITIONS ${CONAN_COMPILE_DEFINITIONS_BZIP2}
|
||||
$<$<CONFIG:Release>:${CONAN_COMPILE_DEFINITIONS_BZIP2_RELEASE}>
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_COMPILE_DEFINITIONS_BZIP2_RELWITHDEBINFO}>
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_COMPILE_DEFINITIONS_BZIP2_MINSIZEREL}>
|
||||
$<$<CONFIG:Debug>:${CONAN_COMPILE_DEFINITIONS_BZIP2_DEBUG}>)
|
||||
set_property(TARGET CONAN_PKG::bzip2 PROPERTY INTERFACE_COMPILE_OPTIONS ${CONAN_C_FLAGS_BZIP2_LIST} ${CONAN_CXX_FLAGS_BZIP2_LIST}
|
||||
$<$<CONFIG:Release>:${CONAN_C_FLAGS_BZIP2_RELEASE_LIST} ${CONAN_CXX_FLAGS_BZIP2_RELEASE_LIST}>
|
||||
$<$<CONFIG:RelWithDebInfo>:${CONAN_C_FLAGS_BZIP2_RELWITHDEBINFO_LIST} ${CONAN_CXX_FLAGS_BZIP2_RELWITHDEBINFO_LIST}>
|
||||
$<$<CONFIG:MinSizeRel>:${CONAN_C_FLAGS_BZIP2_MINSIZEREL_LIST} ${CONAN_CXX_FLAGS_BZIP2_MINSIZEREL_LIST}>
|
||||
$<$<CONFIG:Debug>:${CONAN_C_FLAGS_BZIP2_DEBUG_LIST} ${CONAN_CXX_FLAGS_BZIP2_DEBUG_LIST}>)
|
||||
|
||||
set(CONAN_TARGETS CONAN_PKG::boost CONAN_PKG::zlib CONAN_PKG::bzip2)
|
||||
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_basic_setup)
|
||||
set(options TARGETS NO_OUTPUT_DIRS SKIP_RPATH KEEP_RPATHS SKIP_STD SKIP_FPIC)
|
||||
cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
|
||||
if(CONAN_EXPORTED)
|
||||
conan_message(STATUS "Conan: called by CMake conan helper")
|
||||
endif()
|
||||
|
||||
if(CONAN_IN_LOCAL_CACHE)
|
||||
conan_message(STATUS "Conan: called inside local cache")
|
||||
endif()
|
||||
|
||||
if(NOT ARGUMENTS_NO_OUTPUT_DIRS)
|
||||
conan_message(STATUS "Conan: Adjusting output directories")
|
||||
conan_output_dirs_setup()
|
||||
endif()
|
||||
|
||||
if(NOT ARGUMENTS_TARGETS)
|
||||
conan_message(STATUS "Conan: Using cmake global configuration")
|
||||
conan_global_flags()
|
||||
else()
|
||||
conan_message(STATUS "Conan: Using cmake targets configuration")
|
||||
conan_define_targets()
|
||||
endif()
|
||||
|
||||
if(ARGUMENTS_SKIP_RPATH)
|
||||
# Change by "DEPRECATION" or "SEND_ERROR" when we are ready
|
||||
conan_message(WARNING "Conan: SKIP_RPATH is deprecated, it has been renamed to KEEP_RPATHS")
|
||||
endif()
|
||||
|
||||
if(NOT ARGUMENTS_SKIP_RPATH AND NOT ARGUMENTS_KEEP_RPATHS)
|
||||
# Parameter has renamed, but we keep the compatibility with old SKIP_RPATH
|
||||
conan_set_rpath()
|
||||
endif()
|
||||
|
||||
if(NOT ARGUMENTS_SKIP_STD)
|
||||
conan_set_std()
|
||||
endif()
|
||||
|
||||
if(NOT ARGUMENTS_SKIP_FPIC)
|
||||
conan_set_fpic()
|
||||
endif()
|
||||
|
||||
conan_check_compiler()
|
||||
conan_set_libcxx()
|
||||
conan_set_vs_runtime()
|
||||
conan_set_find_paths()
|
||||
conan_include_build_modules()
|
||||
conan_set_find_library_paths()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_set_find_paths)
|
||||
# CMAKE_MODULE_PATH does not have Debug/Release config, but there are variables
|
||||
# CONAN_CMAKE_MODULE_PATH_DEBUG to be used by the consumer
|
||||
# CMake can find findXXX.cmake files in the root of packages
|
||||
set(CMAKE_MODULE_PATH ${CONAN_CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH})
|
||||
|
||||
# Make find_package() to work
|
||||
set(CMAKE_PREFIX_PATH ${CONAN_CMAKE_MODULE_PATH} ${CMAKE_PREFIX_PATH})
|
||||
|
||||
# Set the find root path (cross build)
|
||||
set(CMAKE_FIND_ROOT_PATH ${CONAN_CMAKE_FIND_ROOT_PATH} ${CMAKE_FIND_ROOT_PATH})
|
||||
if(CONAN_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ${CONAN_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM})
|
||||
endif()
|
||||
if(CONAN_CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ${CONAN_CMAKE_FIND_ROOT_PATH_MODE_LIBRARY})
|
||||
endif()
|
||||
if(CONAN_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ${CONAN_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_set_find_library_paths)
|
||||
# CMAKE_INCLUDE_PATH, CMAKE_LIBRARY_PATH does not have Debug/Release config, but there are variables
|
||||
# CONAN_INCLUDE_DIRS_DEBUG/RELEASE CONAN_LIB_DIRS_DEBUG/RELEASE to be used by the consumer
|
||||
# For find_library
|
||||
set(CMAKE_INCLUDE_PATH ${CONAN_INCLUDE_DIRS} ${CMAKE_INCLUDE_PATH})
|
||||
set(CMAKE_LIBRARY_PATH ${CONAN_LIB_DIRS} ${CMAKE_LIBRARY_PATH})
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_set_vs_runtime)
|
||||
if(CONAN_LINK_RUNTIME)
|
||||
conan_get_policy(CMP0091 policy_0091)
|
||||
if(policy_0091 STREQUAL "NEW")
|
||||
if(CONAN_LINK_RUNTIME MATCHES "MTd")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
|
||||
elseif(CONAN_LINK_RUNTIME MATCHES "MDd")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
|
||||
elseif(CONAN_LINK_RUNTIME MATCHES "MT")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
|
||||
elseif(CONAN_LINK_RUNTIME MATCHES "MD")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
||||
endif()
|
||||
else()
|
||||
foreach(flag CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL)
|
||||
if(DEFINED ${flag})
|
||||
string(REPLACE "/MD" ${CONAN_LINK_RUNTIME} ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(flag CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG)
|
||||
if(DEFINED ${flag})
|
||||
string(REPLACE "/MDd" ${CONAN_LINK_RUNTIME} ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_flags_setup)
|
||||
# Macro maintained for backwards compatibility
|
||||
conan_set_find_library_paths()
|
||||
conan_global_flags()
|
||||
conan_set_rpath()
|
||||
conan_set_vs_runtime()
|
||||
conan_set_libcxx()
|
||||
endmacro()
|
||||
|
||||
|
||||
function(conan_message MESSAGE_OUTPUT)
|
||||
if(NOT CONAN_CMAKE_SILENT_OUTPUT)
|
||||
message(${ARGV${0}})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(conan_get_policy policy_id policy)
|
||||
if(POLICY "${policy_id}")
|
||||
cmake_policy(GET "${policy_id}" _policy)
|
||||
set(${policy} "${_policy}" PARENT_SCOPE)
|
||||
else()
|
||||
set(${policy} "" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(conan_find_libraries_abs_path libraries package_libdir libraries_abs_path)
|
||||
foreach(_LIBRARY_NAME ${libraries})
|
||||
find_library(CONAN_FOUND_LIBRARY NAMES ${_LIBRARY_NAME} PATHS ${package_libdir}
|
||||
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
||||
if(CONAN_FOUND_LIBRARY)
|
||||
conan_message(STATUS "Library ${_LIBRARY_NAME} found ${CONAN_FOUND_LIBRARY}")
|
||||
set(CONAN_FULLPATH_LIBS ${CONAN_FULLPATH_LIBS} ${CONAN_FOUND_LIBRARY})
|
||||
else()
|
||||
conan_message(STATUS "Library ${_LIBRARY_NAME} not found in package, might be system one")
|
||||
set(CONAN_FULLPATH_LIBS ${CONAN_FULLPATH_LIBS} ${_LIBRARY_NAME})
|
||||
endif()
|
||||
unset(CONAN_FOUND_LIBRARY CACHE)
|
||||
endforeach()
|
||||
set(${libraries_abs_path} ${CONAN_FULLPATH_LIBS} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(conan_package_library_targets libraries package_libdir libraries_abs_path deps build_type package_name)
|
||||
unset(_CONAN_ACTUAL_TARGETS CACHE)
|
||||
unset(_CONAN_FOUND_SYSTEM_LIBS CACHE)
|
||||
foreach(_LIBRARY_NAME ${libraries})
|
||||
find_library(CONAN_FOUND_LIBRARY NAMES ${_LIBRARY_NAME} PATHS ${package_libdir}
|
||||
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
||||
if(CONAN_FOUND_LIBRARY)
|
||||
conan_message(STATUS "Library ${_LIBRARY_NAME} found ${CONAN_FOUND_LIBRARY}")
|
||||
set(_LIB_NAME CONAN_LIB::${package_name}_${_LIBRARY_NAME}${build_type})
|
||||
add_library(${_LIB_NAME} UNKNOWN IMPORTED)
|
||||
set_target_properties(${_LIB_NAME} PROPERTIES IMPORTED_LOCATION ${CONAN_FOUND_LIBRARY})
|
||||
set(CONAN_FULLPATH_LIBS ${CONAN_FULLPATH_LIBS} ${_LIB_NAME})
|
||||
set(_CONAN_ACTUAL_TARGETS ${_CONAN_ACTUAL_TARGETS} ${_LIB_NAME})
|
||||
else()
|
||||
conan_message(STATUS "Library ${_LIBRARY_NAME} not found in package, might be system one")
|
||||
set(CONAN_FULLPATH_LIBS ${CONAN_FULLPATH_LIBS} ${_LIBRARY_NAME})
|
||||
set(_CONAN_FOUND_SYSTEM_LIBS "${_CONAN_FOUND_SYSTEM_LIBS};${_LIBRARY_NAME}")
|
||||
endif()
|
||||
unset(CONAN_FOUND_LIBRARY CACHE)
|
||||
endforeach()
|
||||
|
||||
# Add all dependencies to all targets
|
||||
string(REPLACE " " ";" deps_list "${deps}")
|
||||
foreach(_CONAN_ACTUAL_TARGET ${_CONAN_ACTUAL_TARGETS})
|
||||
set_property(TARGET ${_CONAN_ACTUAL_TARGET} PROPERTY INTERFACE_LINK_LIBRARIES "${_CONAN_FOUND_SYSTEM_LIBS};${deps_list}")
|
||||
endforeach()
|
||||
|
||||
set(${libraries_abs_path} ${CONAN_FULLPATH_LIBS} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(conan_set_libcxx)
|
||||
if(DEFINED CONAN_LIBCXX)
|
||||
conan_message(STATUS "Conan: C++ stdlib: ${CONAN_LIBCXX}")
|
||||
if(CONAN_COMPILER STREQUAL "clang" OR CONAN_COMPILER STREQUAL "apple-clang")
|
||||
if(CONAN_LIBCXX STREQUAL "libstdc++" OR CONAN_LIBCXX STREQUAL "libstdc++11" )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
|
||||
elseif(CONAN_LIBCXX STREQUAL "libc++")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
endif()
|
||||
if(CONAN_COMPILER STREQUAL "sun-cc")
|
||||
if(CONAN_LIBCXX STREQUAL "libCstd")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=Cstd")
|
||||
elseif(CONAN_LIBCXX STREQUAL "libstdcxx")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stdcxx4")
|
||||
elseif(CONAN_LIBCXX STREQUAL "libstlport")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4")
|
||||
elseif(CONAN_LIBCXX STREQUAL "libstdc++")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stdcpp")
|
||||
endif()
|
||||
endif()
|
||||
if(CONAN_LIBCXX STREQUAL "libstdc++11")
|
||||
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
|
||||
elseif(CONAN_LIBCXX STREQUAL "libstdc++")
|
||||
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_set_std)
|
||||
conan_message(STATUS "Conan: Adjusting language standard")
|
||||
# Do not warn "Manually-specified variables were not used by the project"
|
||||
set(ignorevar "${CONAN_STD_CXX_FLAG}${CONAN_CMAKE_CXX_STANDARD}${CONAN_CMAKE_CXX_EXTENSIONS}")
|
||||
if (CMAKE_VERSION VERSION_LESS "3.1" OR
|
||||
(CMAKE_VERSION VERSION_LESS "3.12" AND ("${CONAN_CMAKE_CXX_STANDARD}" STREQUAL "20" OR "${CONAN_CMAKE_CXX_STANDARD}" STREQUAL "gnu20")))
|
||||
if(CONAN_STD_CXX_FLAG)
|
||||
conan_message(STATUS "Conan setting CXX_FLAGS flags: ${CONAN_STD_CXX_FLAG}")
|
||||
set(CMAKE_CXX_FLAGS "${CONAN_STD_CXX_FLAG} ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
else()
|
||||
if(CONAN_CMAKE_CXX_STANDARD)
|
||||
conan_message(STATUS "Conan setting CPP STANDARD: ${CONAN_CMAKE_CXX_STANDARD} WITH EXTENSIONS ${CONAN_CMAKE_CXX_EXTENSIONS}")
|
||||
set(CMAKE_CXX_STANDARD ${CONAN_CMAKE_CXX_STANDARD})
|
||||
set(CMAKE_CXX_EXTENSIONS ${CONAN_CMAKE_CXX_EXTENSIONS})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_set_rpath)
|
||||
conan_message(STATUS "Conan: Adjusting default RPATHs Conan policies")
|
||||
if(APPLE)
|
||||
# https://cmake.org/Wiki/CMake_RPATH_handling
|
||||
# CONAN GUIDE: All generated libraries should have the id and dependencies to other
|
||||
# dylibs without path, just the name, EX:
|
||||
# libMyLib1.dylib:
|
||||
# libMyLib1.dylib (compatibility version 0.0.0, current version 0.0.0)
|
||||
# libMyLib0.dylib (compatibility version 0.0.0, current version 0.0.0)
|
||||
# /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
|
||||
# /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
|
||||
# AVOID RPATH FOR *.dylib, ALL LIBS BETWEEN THEM AND THE EXE
|
||||
# SHOULD BE ON THE LINKER RESOLVER PATH (./ IS ONE OF THEM)
|
||||
set(CMAKE_SKIP_RPATH 1 CACHE BOOL "rpaths" FORCE)
|
||||
# Policy CMP0068
|
||||
# We want the old behavior, in CMake >= 3.9 CMAKE_SKIP_RPATH won't affect the install_name in OSX
|
||||
set(CMAKE_INSTALL_NAME_DIR "")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_set_fpic)
|
||||
if(DEFINED CONAN_CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
conan_message(STATUS "Conan: Adjusting fPIC flag (${CONAN_CMAKE_POSITION_INDEPENDENT_CODE})")
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ${CONAN_CMAKE_POSITION_INDEPENDENT_CODE})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_output_dirs_setup)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
|
||||
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_split_version VERSION_STRING MAJOR MINOR)
|
||||
#make a list from the version string
|
||||
string(REPLACE "." ";" VERSION_LIST "${VERSION_STRING}")
|
||||
|
||||
#write output values
|
||||
list(LENGTH VERSION_LIST _version_len)
|
||||
list(GET VERSION_LIST 0 ${MAJOR})
|
||||
if(${_version_len} GREATER 1)
|
||||
list(GET VERSION_LIST 1 ${MINOR})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_error_compiler_version)
|
||||
message(FATAL_ERROR "Detected a mismatch for the compiler version between your conan profile settings and CMake: \n"
|
||||
"Compiler version specified in your conan profile: ${CONAN_COMPILER_VERSION}\n"
|
||||
"Compiler version detected in CMake: ${VERSION_MAJOR}.${VERSION_MINOR}\n"
|
||||
"Please check your conan profile settings (conan profile show [default|your_profile_name])\n"
|
||||
"P.S. You may set CONAN_DISABLE_CHECK_COMPILER CMake variable in order to disable this check."
|
||||
)
|
||||
endmacro()
|
||||
|
||||
set(_CONAN_CURRENT_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
function(conan_get_compiler CONAN_INFO_COMPILER CONAN_INFO_COMPILER_VERSION)
|
||||
conan_message(STATUS "Current conanbuildinfo.cmake directory: " ${_CONAN_CURRENT_DIR})
|
||||
if(NOT EXISTS ${_CONAN_CURRENT_DIR}/conaninfo.txt)
|
||||
conan_message(STATUS "WARN: conaninfo.txt not found")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file (READ "${_CONAN_CURRENT_DIR}/conaninfo.txt" CONANINFO)
|
||||
|
||||
# MATCHALL will match all, including the last one, which is the full_settings one
|
||||
string(REGEX MATCH "full_settings.*" _FULL_SETTINGS_MATCHED ${CONANINFO})
|
||||
string(REGEX MATCH "compiler=([-A-Za-z0-9_ ]+)" _MATCHED ${_FULL_SETTINGS_MATCHED})
|
||||
if(DEFINED CMAKE_MATCH_1)
|
||||
string(STRIP "${CMAKE_MATCH_1}" _CONAN_INFO_COMPILER)
|
||||
set(${CONAN_INFO_COMPILER} ${_CONAN_INFO_COMPILER} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
string(REGEX MATCH "compiler.version=([-A-Za-z0-9_.]+)" _MATCHED ${_FULL_SETTINGS_MATCHED})
|
||||
if(DEFINED CMAKE_MATCH_1)
|
||||
string(STRIP "${CMAKE_MATCH_1}" _CONAN_INFO_COMPILER_VERSION)
|
||||
set(${CONAN_INFO_COMPILER_VERSION} ${_CONAN_INFO_COMPILER_VERSION} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(check_compiler_version)
|
||||
conan_split_version(${CMAKE_CXX_COMPILER_VERSION} VERSION_MAJOR VERSION_MINOR)
|
||||
if(DEFINED CONAN_SETTINGS_COMPILER_TOOLSET)
|
||||
conan_message(STATUS "Conan: Skipping compiler check: Declared 'compiler.toolset'")
|
||||
return()
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
# MSVC_VERSION is defined since 2.8.2 at least
|
||||
# https://cmake.org/cmake/help/v2.8.2/cmake.html#variable:MSVC_VERSION
|
||||
# https://cmake.org/cmake/help/v3.14/variable/MSVC_VERSION.html
|
||||
if(
|
||||
# 1930 = VS 17.0 (v143 toolset)
|
||||
(CONAN_COMPILER_VERSION STREQUAL "17" AND NOT((MSVC_VERSION EQUAL 1930) OR (MSVC_VERSION GREATER 1930))) OR
|
||||
# 1920-1929 = VS 16.0 (v142 toolset)
|
||||
(CONAN_COMPILER_VERSION STREQUAL "16" AND NOT((MSVC_VERSION GREATER 1919) AND (MSVC_VERSION LESS 1930))) OR
|
||||
# 1910-1919 = VS 15.0 (v141 toolset)
|
||||
(CONAN_COMPILER_VERSION STREQUAL "15" AND NOT((MSVC_VERSION GREATER 1909) AND (MSVC_VERSION LESS 1920))) OR
|
||||
# 1900 = VS 14.0 (v140 toolset)
|
||||
(CONAN_COMPILER_VERSION STREQUAL "14" AND NOT(MSVC_VERSION EQUAL 1900)) OR
|
||||
# 1800 = VS 12.0 (v120 toolset)
|
||||
(CONAN_COMPILER_VERSION STREQUAL "12" AND NOT VERSION_MAJOR STREQUAL "18") OR
|
||||
# 1700 = VS 11.0 (v110 toolset)
|
||||
(CONAN_COMPILER_VERSION STREQUAL "11" AND NOT VERSION_MAJOR STREQUAL "17") OR
|
||||
# 1600 = VS 10.0 (v100 toolset)
|
||||
(CONAN_COMPILER_VERSION STREQUAL "10" AND NOT VERSION_MAJOR STREQUAL "16") OR
|
||||
# 1500 = VS 9.0 (v90 toolset)
|
||||
(CONAN_COMPILER_VERSION STREQUAL "9" AND NOT VERSION_MAJOR STREQUAL "15") OR
|
||||
# 1400 = VS 8.0 (v80 toolset)
|
||||
(CONAN_COMPILER_VERSION STREQUAL "8" AND NOT VERSION_MAJOR STREQUAL "14") OR
|
||||
# 1310 = VS 7.1, 1300 = VS 7.0
|
||||
(CONAN_COMPILER_VERSION STREQUAL "7" AND NOT VERSION_MAJOR STREQUAL "13") OR
|
||||
# 1200 = VS 6.0
|
||||
(CONAN_COMPILER_VERSION STREQUAL "6" AND NOT VERSION_MAJOR STREQUAL "12") )
|
||||
conan_error_compiler_version()
|
||||
endif()
|
||||
elseif(CONAN_COMPILER STREQUAL "gcc")
|
||||
conan_split_version(${CONAN_COMPILER_VERSION} CONAN_COMPILER_MAJOR CONAN_COMPILER_MINOR)
|
||||
set(_CHECK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
|
||||
set(_CONAN_VERSION ${CONAN_COMPILER_MAJOR}.${CONAN_COMPILER_MINOR})
|
||||
if(NOT ${CONAN_COMPILER_VERSION} VERSION_LESS 5.0)
|
||||
conan_message(STATUS "Conan: Compiler GCC>=5, checking major version ${CONAN_COMPILER_VERSION}")
|
||||
conan_split_version(${CONAN_COMPILER_VERSION} CONAN_COMPILER_MAJOR CONAN_COMPILER_MINOR)
|
||||
if("${CONAN_COMPILER_MINOR}" STREQUAL "")
|
||||
set(_CHECK_VERSION ${VERSION_MAJOR})
|
||||
set(_CONAN_VERSION ${CONAN_COMPILER_MAJOR})
|
||||
endif()
|
||||
endif()
|
||||
conan_message(STATUS "Conan: Checking correct version: ${_CHECK_VERSION}")
|
||||
if(NOT ${_CHECK_VERSION} VERSION_EQUAL ${_CONAN_VERSION})
|
||||
conan_error_compiler_version()
|
||||
endif()
|
||||
elseif(CONAN_COMPILER STREQUAL "clang")
|
||||
conan_split_version(${CONAN_COMPILER_VERSION} CONAN_COMPILER_MAJOR CONAN_COMPILER_MINOR)
|
||||
set(_CHECK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
|
||||
set(_CONAN_VERSION ${CONAN_COMPILER_MAJOR}.${CONAN_COMPILER_MINOR})
|
||||
if(NOT ${CONAN_COMPILER_VERSION} VERSION_LESS 8.0)
|
||||
conan_message(STATUS "Conan: Compiler Clang>=8, checking major version ${CONAN_COMPILER_VERSION}")
|
||||
if("${CONAN_COMPILER_MINOR}" STREQUAL "")
|
||||
set(_CHECK_VERSION ${VERSION_MAJOR})
|
||||
set(_CONAN_VERSION ${CONAN_COMPILER_MAJOR})
|
||||
endif()
|
||||
endif()
|
||||
conan_message(STATUS "Conan: Checking correct version: ${_CHECK_VERSION}")
|
||||
if(NOT ${_CHECK_VERSION} VERSION_EQUAL ${_CONAN_VERSION})
|
||||
conan_error_compiler_version()
|
||||
endif()
|
||||
elseif(CONAN_COMPILER STREQUAL "apple-clang" OR CONAN_COMPILER STREQUAL "sun-cc" OR CONAN_COMPILER STREQUAL "mcst-lcc")
|
||||
conan_split_version(${CONAN_COMPILER_VERSION} CONAN_COMPILER_MAJOR CONAN_COMPILER_MINOR)
|
||||
if(${CONAN_COMPILER_MAJOR} VERSION_GREATER_EQUAL "13" AND "${CONAN_COMPILER_MINOR}" STREQUAL "" AND ${CONAN_COMPILER_MAJOR} VERSION_EQUAL ${VERSION_MAJOR})
|
||||
# This is correct, 13.X is considered 13
|
||||
elseif(NOT ${VERSION_MAJOR}.${VERSION_MINOR} VERSION_EQUAL ${CONAN_COMPILER_MAJOR}.${CONAN_COMPILER_MINOR})
|
||||
conan_error_compiler_version()
|
||||
endif()
|
||||
elseif(CONAN_COMPILER STREQUAL "intel")
|
||||
conan_split_version(${CONAN_COMPILER_VERSION} CONAN_COMPILER_MAJOR CONAN_COMPILER_MINOR)
|
||||
if(NOT ${CONAN_COMPILER_VERSION} VERSION_LESS 19.1)
|
||||
if(NOT ${VERSION_MAJOR}.${VERSION_MINOR} VERSION_EQUAL ${CONAN_COMPILER_MAJOR}.${CONAN_COMPILER_MINOR})
|
||||
conan_error_compiler_version()
|
||||
endif()
|
||||
else()
|
||||
if(NOT ${VERSION_MAJOR} VERSION_EQUAL ${CONAN_COMPILER_MAJOR})
|
||||
conan_error_compiler_version()
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
conan_message(STATUS "WARN: Unknown compiler '${CONAN_COMPILER}', skipping the version check...")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(conan_check_compiler)
|
||||
if(CONAN_DISABLE_CHECK_COMPILER)
|
||||
conan_message(STATUS "WARN: Disabled conan compiler checks")
|
||||
return()
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_CXX_COMPILER_ID)
|
||||
if(DEFINED CMAKE_C_COMPILER_ID)
|
||||
conan_message(STATUS "This project seems to be plain C, using '${CMAKE_C_COMPILER_ID}' compiler")
|
||||
set(CMAKE_CXX_COMPILER_ID ${CMAKE_C_COMPILER_ID})
|
||||
set(CMAKE_CXX_COMPILER_VERSION ${CMAKE_C_COMPILER_VERSION})
|
||||
else()
|
||||
message(FATAL_ERROR "This project seems to be plain C, but no compiler defined")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT CMAKE_CXX_COMPILER_ID AND NOT CMAKE_C_COMPILER_ID)
|
||||
# This use case happens when compiler is not identified by CMake, but the compilers are there and work
|
||||
conan_message(STATUS "*** WARN: CMake was not able to identify a C or C++ compiler ***")
|
||||
conan_message(STATUS "*** WARN: Disabling compiler checks. Please make sure your settings match your environment ***")
|
||||
return()
|
||||
endif()
|
||||
if(NOT DEFINED CONAN_COMPILER)
|
||||
conan_get_compiler(CONAN_COMPILER CONAN_COMPILER_VERSION)
|
||||
if(NOT DEFINED CONAN_COMPILER)
|
||||
conan_message(STATUS "WARN: CONAN_COMPILER variable not set, please make sure yourself that "
|
||||
"your compiler and version matches your declared settings")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL ${CMAKE_SYSTEM_NAME})
|
||||
set(CROSS_BUILDING 1)
|
||||
endif()
|
||||
|
||||
# If using VS, verify toolset
|
||||
if (CONAN_COMPILER STREQUAL "Visual Studio")
|
||||
if (CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "LLVM" OR
|
||||
CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "llvm" OR
|
||||
CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "clang" OR
|
||||
CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "Clang")
|
||||
set(EXPECTED_CMAKE_CXX_COMPILER_ID "Clang")
|
||||
elseif (CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "Intel")
|
||||
set(EXPECTED_CMAKE_CXX_COMPILER_ID "Intel")
|
||||
else()
|
||||
set(EXPECTED_CMAKE_CXX_COMPILER_ID "MSVC")
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_CXX_COMPILER_ID MATCHES ${EXPECTED_CMAKE_CXX_COMPILER_ID})
|
||||
message(FATAL_ERROR "Incorrect '${CONAN_COMPILER}'. Toolset specifies compiler as '${EXPECTED_CMAKE_CXX_COMPILER_ID}' "
|
||||
"but CMake detected '${CMAKE_CXX_COMPILER_ID}'")
|
||||
endif()
|
||||
|
||||
# Avoid checks when cross compiling, apple-clang crashes because its APPLE but not apple-clang
|
||||
# Actually CMake is detecting "clang" when you are using apple-clang, only if CMP0025 is set to NEW will detect apple-clang
|
||||
elseif((CONAN_COMPILER STREQUAL "gcc" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR
|
||||
(CONAN_COMPILER STREQUAL "apple-clang" AND NOT CROSS_BUILDING AND (NOT APPLE OR NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")) OR
|
||||
(CONAN_COMPILER STREQUAL "clang" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR
|
||||
(CONAN_COMPILER STREQUAL "sun-cc" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "SunPro") )
|
||||
message(FATAL_ERROR "Incorrect '${CONAN_COMPILER}', is not the one detected by CMake: '${CMAKE_CXX_COMPILER_ID}'")
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT DEFINED CONAN_COMPILER_VERSION)
|
||||
conan_message(STATUS "WARN: CONAN_COMPILER_VERSION variable not set, please make sure yourself "
|
||||
"that your compiler version matches your declared settings")
|
||||
return()
|
||||
endif()
|
||||
check_compiler_version()
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(conan_set_flags build_type)
|
||||
set(CMAKE_CXX_FLAGS${build_type} "${CMAKE_CXX_FLAGS${build_type}} ${CONAN_CXX_FLAGS${build_type}}")
|
||||
set(CMAKE_C_FLAGS${build_type} "${CMAKE_C_FLAGS${build_type}} ${CONAN_C_FLAGS${build_type}}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS${build_type} "${CMAKE_SHARED_LINKER_FLAGS${build_type}} ${CONAN_SHARED_LINKER_FLAGS${build_type}}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS${build_type} "${CMAKE_EXE_LINKER_FLAGS${build_type}} ${CONAN_EXE_LINKER_FLAGS${build_type}}")
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_global_flags)
|
||||
if(CONAN_SYSTEM_INCLUDES)
|
||||
include_directories(SYSTEM ${CONAN_INCLUDE_DIRS}
|
||||
"$<$<CONFIG:Release>:${CONAN_INCLUDE_DIRS_RELEASE}>"
|
||||
"$<$<CONFIG:RelWithDebInfo>:${CONAN_INCLUDE_DIRS_RELWITHDEBINFO}>"
|
||||
"$<$<CONFIG:MinSizeRel>:${CONAN_INCLUDE_DIRS_MINSIZEREL}>"
|
||||
"$<$<CONFIG:Debug>:${CONAN_INCLUDE_DIRS_DEBUG}>")
|
||||
else()
|
||||
include_directories(${CONAN_INCLUDE_DIRS}
|
||||
"$<$<CONFIG:Release>:${CONAN_INCLUDE_DIRS_RELEASE}>"
|
||||
"$<$<CONFIG:RelWithDebInfo>:${CONAN_INCLUDE_DIRS_RELWITHDEBINFO}>"
|
||||
"$<$<CONFIG:MinSizeRel>:${CONAN_INCLUDE_DIRS_MINSIZEREL}>"
|
||||
"$<$<CONFIG:Debug>:${CONAN_INCLUDE_DIRS_DEBUG}>")
|
||||
endif()
|
||||
|
||||
link_directories(${CONAN_LIB_DIRS})
|
||||
|
||||
conan_find_libraries_abs_path("${CONAN_LIBS_DEBUG}" "${CONAN_LIB_DIRS_DEBUG}"
|
||||
CONAN_LIBS_DEBUG)
|
||||
conan_find_libraries_abs_path("${CONAN_LIBS_RELEASE}" "${CONAN_LIB_DIRS_RELEASE}"
|
||||
CONAN_LIBS_RELEASE)
|
||||
conan_find_libraries_abs_path("${CONAN_LIBS_RELWITHDEBINFO}" "${CONAN_LIB_DIRS_RELWITHDEBINFO}"
|
||||
CONAN_LIBS_RELWITHDEBINFO)
|
||||
conan_find_libraries_abs_path("${CONAN_LIBS_MINSIZEREL}" "${CONAN_LIB_DIRS_MINSIZEREL}"
|
||||
CONAN_LIBS_MINSIZEREL)
|
||||
|
||||
add_compile_options(${CONAN_DEFINES}
|
||||
"$<$<CONFIG:Debug>:${CONAN_DEFINES_DEBUG}>"
|
||||
"$<$<CONFIG:Release>:${CONAN_DEFINES_RELEASE}>"
|
||||
"$<$<CONFIG:RelWithDebInfo>:${CONAN_DEFINES_RELWITHDEBINFO}>"
|
||||
"$<$<CONFIG:MinSizeRel>:${CONAN_DEFINES_MINSIZEREL}>")
|
||||
|
||||
conan_set_flags("")
|
||||
conan_set_flags("_RELEASE")
|
||||
conan_set_flags("_DEBUG")
|
||||
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_target_link_libraries target)
|
||||
if(CONAN_TARGETS)
|
||||
target_link_libraries(${target} ${CONAN_TARGETS})
|
||||
else()
|
||||
target_link_libraries(${target} ${CONAN_LIBS})
|
||||
foreach(_LIB ${CONAN_LIBS_RELEASE})
|
||||
target_link_libraries(${target} optimized ${_LIB})
|
||||
endforeach()
|
||||
foreach(_LIB ${CONAN_LIBS_DEBUG})
|
||||
target_link_libraries(${target} debug ${_LIB})
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(conan_include_build_modules)
|
||||
if(CMAKE_BUILD_TYPE)
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
set(CONAN_BUILD_MODULES_PATHS ${CONAN_BUILD_MODULES_PATHS_DEBUG} ${CONAN_BUILD_MODULES_PATHS})
|
||||
elseif(${CMAKE_BUILD_TYPE} MATCHES "Release")
|
||||
set(CONAN_BUILD_MODULES_PATHS ${CONAN_BUILD_MODULES_PATHS_RELEASE} ${CONAN_BUILD_MODULES_PATHS})
|
||||
elseif(${CMAKE_BUILD_TYPE} MATCHES "RelWithDebInfo")
|
||||
set(CONAN_BUILD_MODULES_PATHS ${CONAN_BUILD_MODULES_PATHS_RELWITHDEBINFO} ${CONAN_BUILD_MODULES_PATHS})
|
||||
elseif(${CMAKE_BUILD_TYPE} MATCHES "MinSizeRel")
|
||||
set(CONAN_BUILD_MODULES_PATHS ${CONAN_BUILD_MODULES_PATHS_MINSIZEREL} ${CONAN_BUILD_MODULES_PATHS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(_BUILD_MODULE_PATH ${CONAN_BUILD_MODULES_PATHS})
|
||||
include(${_BUILD_MODULE_PATH})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
### Definition of user declared vars (user_info) ###
|
||||
|
||||
set(CONAN_USER_BOOST_stacktrace_addr2line_available "False")
|
||||
@@ -1,353 +0,0 @@
|
||||
[includedirs]
|
||||
C:/.conan/029ec3/1/include
|
||||
C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/include
|
||||
C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/include
|
||||
|
||||
[libdirs]
|
||||
C:/.conan/029ec3/1/lib
|
||||
C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/lib
|
||||
C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/lib
|
||||
|
||||
[bindirs]
|
||||
C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/bin
|
||||
|
||||
[resdirs]
|
||||
|
||||
|
||||
[builddirs]
|
||||
C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/
|
||||
C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/
|
||||
|
||||
[libs]
|
||||
libboost_contract
|
||||
libboost_coroutine
|
||||
libboost_context
|
||||
libboost_graph
|
||||
libboost_iostreams
|
||||
libboost_json
|
||||
libboost_locale
|
||||
libboost_log_setup
|
||||
libboost_log
|
||||
libboost_math_c99
|
||||
libboost_math_c99f
|
||||
libboost_math_c99l
|
||||
libboost_math_tr1
|
||||
libboost_math_tr1f
|
||||
libboost_math_tr1l
|
||||
libboost_nowide
|
||||
libboost_program_options
|
||||
libboost_random
|
||||
libboost_regex
|
||||
libboost_stacktrace_noop
|
||||
libboost_stacktrace_windbg
|
||||
libboost_stacktrace_windbg_cached
|
||||
libboost_timer
|
||||
libboost_type_erasure
|
||||
libboost_thread
|
||||
libboost_chrono
|
||||
libboost_container
|
||||
libboost_date_time
|
||||
libboost_unit_test_framework
|
||||
libboost_prg_exec_monitor
|
||||
libboost_test_exec_monitor
|
||||
libboost_exception
|
||||
libboost_url
|
||||
libboost_wave
|
||||
libboost_filesystem
|
||||
libboost_atomic
|
||||
libboost_wserialization
|
||||
libboost_serialization
|
||||
zlib
|
||||
bz2
|
||||
|
||||
[system_libs]
|
||||
ole32
|
||||
dbgeng
|
||||
bcrypt
|
||||
ntdll
|
||||
shell32
|
||||
Advapi32
|
||||
user32
|
||||
|
||||
[defines]
|
||||
BOOST_STACKTRACE_USE_NOOP
|
||||
BOOST_STACKTRACE_USE_WINDBG
|
||||
BOOST_STACKTRACE_USE_WINDBG_CACHED
|
||||
BOOST_ALL_NO_LIB
|
||||
|
||||
[cppflags]
|
||||
|
||||
|
||||
[cxxflags]
|
||||
|
||||
|
||||
[cflags]
|
||||
|
||||
|
||||
[sharedlinkflags]
|
||||
|
||||
|
||||
[exelinkflags]
|
||||
|
||||
|
||||
[sysroot]
|
||||
|
||||
|
||||
[frameworks]
|
||||
|
||||
|
||||
[frameworkdirs]
|
||||
|
||||
|
||||
|
||||
[includedirs_boost]
|
||||
C:/.conan/029ec3/1/include
|
||||
|
||||
[libdirs_boost]
|
||||
C:/.conan/029ec3/1/lib
|
||||
|
||||
[bindirs_boost]
|
||||
|
||||
|
||||
[resdirs_boost]
|
||||
|
||||
|
||||
[builddirs_boost]
|
||||
|
||||
|
||||
[libs_boost]
|
||||
libboost_contract
|
||||
libboost_coroutine
|
||||
libboost_context
|
||||
libboost_graph
|
||||
libboost_iostreams
|
||||
libboost_json
|
||||
libboost_locale
|
||||
libboost_log_setup
|
||||
libboost_log
|
||||
libboost_math_c99
|
||||
libboost_math_c99f
|
||||
libboost_math_c99l
|
||||
libboost_math_tr1
|
||||
libboost_math_tr1f
|
||||
libboost_math_tr1l
|
||||
libboost_nowide
|
||||
libboost_program_options
|
||||
libboost_random
|
||||
libboost_regex
|
||||
libboost_stacktrace_noop
|
||||
libboost_stacktrace_windbg
|
||||
libboost_stacktrace_windbg_cached
|
||||
libboost_timer
|
||||
libboost_type_erasure
|
||||
libboost_thread
|
||||
libboost_chrono
|
||||
libboost_container
|
||||
libboost_date_time
|
||||
libboost_unit_test_framework
|
||||
libboost_prg_exec_monitor
|
||||
libboost_test_exec_monitor
|
||||
libboost_exception
|
||||
libboost_url
|
||||
libboost_wave
|
||||
libboost_filesystem
|
||||
libboost_atomic
|
||||
libboost_wserialization
|
||||
libboost_serialization
|
||||
|
||||
[system_libs_boost]
|
||||
ole32
|
||||
dbgeng
|
||||
bcrypt
|
||||
ntdll
|
||||
shell32
|
||||
Advapi32
|
||||
user32
|
||||
|
||||
[defines_boost]
|
||||
BOOST_STACKTRACE_USE_NOOP
|
||||
BOOST_STACKTRACE_USE_WINDBG
|
||||
BOOST_STACKTRACE_USE_WINDBG_CACHED
|
||||
BOOST_ALL_NO_LIB
|
||||
|
||||
[cppflags_boost]
|
||||
|
||||
|
||||
[cxxflags_boost]
|
||||
|
||||
|
||||
[cflags_boost]
|
||||
|
||||
|
||||
[sharedlinkflags_boost]
|
||||
|
||||
|
||||
[exelinkflags_boost]
|
||||
|
||||
|
||||
[sysroot_boost]
|
||||
|
||||
|
||||
[frameworks_boost]
|
||||
|
||||
|
||||
[frameworkdirs_boost]
|
||||
|
||||
|
||||
[rootpath_boost]
|
||||
C:/.conan/029ec3/1
|
||||
|
||||
[name_boost]
|
||||
boost
|
||||
|
||||
[version_boost]
|
||||
1.84.0
|
||||
|
||||
[generatornames_boost]
|
||||
cmake_find_package=Boost
|
||||
cmake_find_package_multi=Boost
|
||||
|
||||
[generatorfilenames_boost]
|
||||
cmake_find_package=Boost
|
||||
cmake_find_package_multi=Boost
|
||||
|
||||
|
||||
[includedirs_zlib]
|
||||
C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/include
|
||||
|
||||
[libdirs_zlib]
|
||||
C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/lib
|
||||
|
||||
[bindirs_zlib]
|
||||
|
||||
|
||||
[resdirs_zlib]
|
||||
|
||||
|
||||
[builddirs_zlib]
|
||||
C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b/
|
||||
|
||||
[libs_zlib]
|
||||
zlib
|
||||
|
||||
[system_libs_zlib]
|
||||
|
||||
|
||||
[defines_zlib]
|
||||
|
||||
|
||||
[cppflags_zlib]
|
||||
|
||||
|
||||
[cxxflags_zlib]
|
||||
|
||||
|
||||
[cflags_zlib]
|
||||
|
||||
|
||||
[sharedlinkflags_zlib]
|
||||
|
||||
|
||||
[exelinkflags_zlib]
|
||||
|
||||
|
||||
[sysroot_zlib]
|
||||
|
||||
|
||||
[frameworks_zlib]
|
||||
|
||||
|
||||
[frameworkdirs_zlib]
|
||||
|
||||
|
||||
[rootpath_zlib]
|
||||
C:/Users/Антон/.conan/data/zlib/1.3.1/_/_/package/5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b
|
||||
|
||||
[name_zlib]
|
||||
zlib
|
||||
|
||||
[version_zlib]
|
||||
1.3.1
|
||||
|
||||
[generatornames_zlib]
|
||||
cmake_find_package=ZLIB
|
||||
cmake_find_package_multi=ZLIB
|
||||
|
||||
[generatorfilenames_zlib]
|
||||
|
||||
|
||||
|
||||
[includedirs_bzip2]
|
||||
C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/include
|
||||
|
||||
[libdirs_bzip2]
|
||||
C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/lib
|
||||
|
||||
[bindirs_bzip2]
|
||||
C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/bin
|
||||
|
||||
[resdirs_bzip2]
|
||||
|
||||
|
||||
[builddirs_bzip2]
|
||||
C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201/
|
||||
|
||||
[libs_bzip2]
|
||||
bz2
|
||||
|
||||
[system_libs_bzip2]
|
||||
|
||||
|
||||
[defines_bzip2]
|
||||
|
||||
|
||||
[cppflags_bzip2]
|
||||
|
||||
|
||||
[cxxflags_bzip2]
|
||||
|
||||
|
||||
[cflags_bzip2]
|
||||
|
||||
|
||||
[sharedlinkflags_bzip2]
|
||||
|
||||
|
||||
[exelinkflags_bzip2]
|
||||
|
||||
|
||||
[sysroot_bzip2]
|
||||
|
||||
|
||||
[frameworks_bzip2]
|
||||
|
||||
|
||||
[frameworkdirs_bzip2]
|
||||
|
||||
|
||||
[rootpath_bzip2]
|
||||
C:/Users/Антон/.conan/data/bzip2/1.0.8/_/_/package/53b5fd22ba061620078deefdae9a437c5f693201
|
||||
|
||||
[name_bzip2]
|
||||
bzip2
|
||||
|
||||
[version_bzip2]
|
||||
1.0.8
|
||||
|
||||
[generatornames_bzip2]
|
||||
cmake_find_package=BZip2
|
||||
cmake_find_package_multi=BZip2
|
||||
|
||||
[generatorfilenames_bzip2]
|
||||
|
||||
|
||||
|
||||
[USER_boost]
|
||||
stacktrace_addr2line_available=False
|
||||
[USER_bzip2]
|
||||
[USER_zlib]
|
||||
[ENV_boost]
|
||||
BOOST_ROOT=C:\.conan\029ec3\1
|
||||
[ENV_zlib]
|
||||
[ENV_bzip2]
|
||||
PATH=["C:\Users\Антон\.conan\data\bzip2\1.0.8\_\_\package\53b5fd22ba061620078deefdae9a437c5f693201\bin"]
|
||||
@@ -1,102 +0,0 @@
|
||||
[settings]
|
||||
arch=x86_64
|
||||
build_type=Release
|
||||
compiler=Visual Studio
|
||||
compiler.runtime=MD
|
||||
compiler.version=17
|
||||
os=Windows
|
||||
|
||||
[requires]
|
||||
boost/1.Y.Z
|
||||
|
||||
[options]
|
||||
|
||||
|
||||
[full_settings]
|
||||
arch=x86_64
|
||||
arch_build=x86_64
|
||||
build_type=Release
|
||||
compiler=Visual Studio
|
||||
compiler.runtime=MD
|
||||
compiler.version=17
|
||||
os=Windows
|
||||
os_build=Windows
|
||||
|
||||
[full_requires]
|
||||
boost/1.84.0:e50863e182b9f1a9ce9e711c031065f1fe5f7f78
|
||||
bzip2/1.0.8:53b5fd22ba061620078deefdae9a437c5f693201
|
||||
zlib/1.3.1:5a61a86bb3e07ce4262c80e1510f9c05e9b6d48b
|
||||
|
||||
[full_options]
|
||||
boost:asio_no_deprecated=False
|
||||
boost:buildid=None
|
||||
boost:bzip2=True
|
||||
boost:debug_level=0
|
||||
boost:diagnostic_definitions=False
|
||||
boost:error_code_header_only=False
|
||||
boost:extra_b2_flags=None
|
||||
boost:filesystem_no_deprecated=False
|
||||
boost:filesystem_use_std_fs=False
|
||||
boost:filesystem_version=None
|
||||
boost:header_only=False
|
||||
boost:i18n_backend=deprecated
|
||||
boost:i18n_backend_iconv=off
|
||||
boost:i18n_backend_icu=False
|
||||
boost:layout=system
|
||||
boost:lzma=False
|
||||
boost:magic_autolink=False
|
||||
boost:multithreading=True
|
||||
boost:namespace=boost
|
||||
boost:namespace_alias=False
|
||||
boost:pch=True
|
||||
boost:python_executable=None
|
||||
boost:python_version=None
|
||||
boost:segmented_stacks=False
|
||||
boost:shared=False
|
||||
boost:system_no_deprecated=False
|
||||
boost:system_use_utf8=False
|
||||
boost:visibility=hidden
|
||||
boost:without_atomic=False
|
||||
boost:without_chrono=False
|
||||
boost:without_cobalt=True
|
||||
boost:without_container=False
|
||||
boost:without_context=False
|
||||
boost:without_contract=False
|
||||
boost:without_coroutine=False
|
||||
boost:without_date_time=False
|
||||
boost:without_exception=False
|
||||
boost:without_fiber=True
|
||||
boost:without_filesystem=False
|
||||
boost:without_graph=False
|
||||
boost:without_graph_parallel=True
|
||||
boost:without_iostreams=False
|
||||
boost:without_json=False
|
||||
boost:without_locale=False
|
||||
boost:without_log=False
|
||||
boost:without_math=False
|
||||
boost:without_mpi=True
|
||||
boost:without_nowide=False
|
||||
boost:without_program_options=False
|
||||
boost:without_python=True
|
||||
boost:without_random=False
|
||||
boost:without_regex=False
|
||||
boost:without_serialization=False
|
||||
boost:without_stacktrace=False
|
||||
boost:without_system=False
|
||||
boost:without_test=False
|
||||
boost:without_thread=False
|
||||
boost:without_timer=False
|
||||
boost:without_type_erasure=False
|
||||
boost:without_url=False
|
||||
boost:without_wave=False
|
||||
boost:zlib=True
|
||||
boost:zstd=False
|
||||
bzip2:build_executable=True
|
||||
bzip2:shared=False
|
||||
zlib:shared=False
|
||||
|
||||
[recipe_hash]
|
||||
|
||||
|
||||
[env]
|
||||
|
||||
@@ -1,274 +0,0 @@
|
||||
{
|
||||
"options": [
|
||||
[
|
||||
"boost:asio_no_deprecated",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:buildid",
|
||||
"None"
|
||||
],
|
||||
[
|
||||
"boost:bzip2",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"boost:debug_level",
|
||||
"0"
|
||||
],
|
||||
[
|
||||
"boost:diagnostic_definitions",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:error_code_header_only",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:extra_b2_flags",
|
||||
"None"
|
||||
],
|
||||
[
|
||||
"boost:filesystem_no_deprecated",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:filesystem_use_std_fs",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:filesystem_version",
|
||||
"None"
|
||||
],
|
||||
[
|
||||
"boost:header_only",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:i18n_backend",
|
||||
"deprecated"
|
||||
],
|
||||
[
|
||||
"boost:i18n_backend_iconv",
|
||||
"off"
|
||||
],
|
||||
[
|
||||
"boost:i18n_backend_icu",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:layout",
|
||||
"system"
|
||||
],
|
||||
[
|
||||
"boost:lzma",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:magic_autolink",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:multithreading",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"boost:namespace",
|
||||
"boost"
|
||||
],
|
||||
[
|
||||
"boost:namespace_alias",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:pch",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"boost:python_executable",
|
||||
"None"
|
||||
],
|
||||
[
|
||||
"boost:python_version",
|
||||
"None"
|
||||
],
|
||||
[
|
||||
"boost:segmented_stacks",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:shared",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:system_no_deprecated",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:system_use_utf8",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:visibility",
|
||||
"hidden"
|
||||
],
|
||||
[
|
||||
"boost:without_atomic",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_chrono",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_cobalt",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"boost:without_container",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_context",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_contract",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_coroutine",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_date_time",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_exception",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_fiber",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"boost:without_filesystem",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_graph",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_graph_parallel",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"boost:without_iostreams",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_json",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_locale",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_log",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_math",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_mpi",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"boost:without_nowide",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_program_options",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_python",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"boost:without_random",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_regex",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_serialization",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_stacktrace",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_system",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_test",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_thread",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_timer",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_type_erasure",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_url",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:without_wave",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"boost:zlib",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"boost:zstd",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"bzip2:build_executable",
|
||||
"True"
|
||||
],
|
||||
[
|
||||
"bzip2:shared",
|
||||
"False"
|
||||
],
|
||||
[
|
||||
"zlib:shared",
|
||||
"False"
|
||||
]
|
||||
],
|
||||
"root": {
|
||||
"name": null,
|
||||
"version": null,
|
||||
"user": null,
|
||||
"channel": null
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
[requires]
|
||||
boost/1.84.0
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
@@ -0,0 +1,188 @@
|
||||
-- Общая рекомендация - расписать use-case'ы
|
||||
|
||||
CREATE SCHEMA `up_and_down` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
CREATE TABLE `up_and_down`.`users` (
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`login` VARCHAR(128) UNIQUE NOT NULL,
|
||||
`hashed_password` TEXT NOT NULL,
|
||||
PRIMARY KEY (`uuid`),
|
||||
UNIQUE INDEX `uuid_UNIQUE` (`uuid` ASC)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`mania` (
|
||||
`level` INT1 NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
PRIMARY KEY (`level`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`depressions` (
|
||||
`level` INT1 NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
PRIMARY KEY (`level`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`moods` (
|
||||
`level` INT1 NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
PRIMARY KEY (`level`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`activities` (
|
||||
`level` INT1 NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
PRIMARY KEY (`level`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`appetites` (
|
||||
`level` INT1 NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
PRIMARY KEY (`level`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`dreams` (
|
||||
`level` INT1 NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
PRIMARY KEY (`level`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`anxiety` (
|
||||
`level` INT1 NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
PRIMARY KEY (`level`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`user_treatment_schemes` (
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`user_uuid` CHAR(36) NOT NULL,
|
||||
`treatment_name` TEXT NOT NULL,
|
||||
`instructions` TEXT,
|
||||
PRIMARY KEY (`uuid`),
|
||||
FOREIGN KEY (`user_uuid`) REFERENCES `users`(`uuid`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`diaries` (
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`user_uuid` CHAR(36) NOT NULL,
|
||||
`time` DATETIME NOT NULL,
|
||||
`mania_level` INT1 NOT NULL,
|
||||
`depression_level` INT1 NOT NULL,
|
||||
`mood_level` INT1 NOT NULL,
|
||||
`activity_level` INT1 NOT NULL,
|
||||
`appetite_level` INT1 NOT NULL,
|
||||
`dream_level` INT1 NOT NULL,
|
||||
`anxiety_level` INT1 NOT NULL,
|
||||
`user_treatment_schemes_uuid` CHAR(36),
|
||||
PRIMARY KEY (`uuid`),
|
||||
FOREIGN KEY (`user_uuid`) REFERENCES `users`(`uuid`),
|
||||
FOREIGN KEY (`mania_level`) REFERENCES `mania`(`level`),
|
||||
FOREIGN KEY (`depression_level`) REFERENCES `depressions`(`level`),
|
||||
FOREIGN KEY (`mood_level`) REFERENCES `moods`(`level`),
|
||||
FOREIGN KEY (`activity_level`) REFERENCES `activities`(`level`),
|
||||
FOREIGN KEY (`appetite_level`) REFERENCES `appetites`(`level`),
|
||||
FOREIGN KEY (`dream_level`) REFERENCES `dreams`(`level`),
|
||||
FOREIGN KEY (`anxiety_level`) REFERENCES `anxiety`(`level`),
|
||||
FOREIGN KEY (`user_treatment_schemes_uuid`) REFERENCES `user_treatment_schemes`(`uuid`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`medications` (
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`name` TEXT NOT NULL,
|
||||
`dose` int8 NOT NULL,
|
||||
`unit` CHAR(30),
|
||||
`is_urgent` BOOL NOT NULL,
|
||||
PRIMARY KEY (`uuid`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`treatment_schemes` (
|
||||
`user_treatment_schemes_uuid` CHAR(36) NOT NULL,
|
||||
`medication_uuid` CHAR(36) NOT NULL,
|
||||
PRIMARY KEY (`user_treatment_schemes_uuid`, `medication_uuid`),
|
||||
FOREIGN KEY (`user_treatment_schemes_uuid`) REFERENCES `user_treatment_schemes`(`uuid`),
|
||||
FOREIGN KEY (`medication_uuid`) REFERENCES `medications`(`uuid`)
|
||||
);
|
||||
|
||||
-- insert constants
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (1, 'Полное отсутствие мании');
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (2, 'Слегка приподнятое настроение');
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (3, 'Хорошее настроение');
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (4, 'Очень хорошее настроение, но в рамках разумного');
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (5, 'Гипомания I, характерная для циклотимии - приятная эйфория, повышенная активность');
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (6, 'Гипомания II, характерная для БАР II - все, что в предыдущем пункте + белеет в глазах');
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (7, 'Мания I - периодический не сильный отрыв от реальности');
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (8, 'Мания II - сопровождается бредом и галлюцинациями - неадекватная речь');
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (9, 'Мания III - сопровождается бредом и галлюцинациями - неадекватное поведение');
|
||||
INSERT INTO `up_and_down`.`mania` (`level`, `description`) VALUES (10, 'Мания IV - сопровождается бредом и галлюцинациями - человек опасен для себя и других');
|
||||
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (1, 'Депрессия I');
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (2, 'Депрессия II');
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (3, 'Депрессия III');
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (4, 'Депрессия IV');
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (5, 'Депрессия V');
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (6, 'Депрессия VI');
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (7, 'Депрессия VII');
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (8, 'Депрессия VIII');
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (9, 'Депрессия IX');
|
||||
INSERT INTO `up_and_down`.`depressions` (`level`, `description`) VALUES (10, 'Депрессия X');
|
||||
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (1, 'Настроение I');
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (2, 'Настроение II');
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (3, 'Настроение III');
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (4, 'Настроение IV');
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (5, 'Настроение V');
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (6, 'Настроение VI');
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (7, 'Настроение VII');
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (8, 'Настроение VIII');
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (9, 'Настроение IX');
|
||||
INSERT INTO `up_and_down`.`moods` (`level`, `description`) VALUES (10, 'Настроение X');
|
||||
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (1, 'Активность I');
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (2, 'Активность II');
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (3, 'Активность III');
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (4, 'Активность IV');
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (5, 'Активность V');
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (6, 'Активность VI');
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (7, 'Активность VII');
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (8, 'Активность VIII');
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (9, 'Активность IX');
|
||||
INSERT INTO `up_and_down`.`activities` (`level`, `description`) VALUES (10, 'Активность X');
|
||||
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (1, 'Аппетит I');
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (2, 'Аппетит II');
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (3, 'Аппетит III');
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (4, 'Аппетит IV');
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (5, 'Аппетит V');
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (6, 'Аппетит VI');
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (7, 'Аппетит VII');
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (8, 'Аппетит VIII');
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (9, 'Аппетит IX');
|
||||
INSERT INTO `up_and_down`.`appetites` (`level`, `description`) VALUES (10, 'Аппетит X');
|
||||
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (1, 'Сон I');
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (2, 'Сон II');
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (3, 'Сон III');
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (4, 'Сон IV');
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (5, 'Сон V');
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (6, 'Сон VI');
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (7, 'Сон VII');
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (8, 'Сон VIII');
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (9, 'Сон IX');
|
||||
INSERT INTO `up_and_down`.`dreams` (`level`, `description`) VALUES (10, 'Сон X');
|
||||
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (1, 'Тревога I');
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (2, 'Тревога II');
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (3, 'Тревога III');
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (4, 'Тревога IV');
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (5, 'Тревога V');
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (6, 'Тревога VI');
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (7, 'Тревога VII');
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (8, 'Тревога VIII');
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (9, 'Тревога IX');
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (10, 'Тревога X');
|
||||
|
||||
-- Заполнение пользователями
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('ab555fcb-b9ee-45f4-9de8-8f16daa5d03b', 'login1', 'Qwerty12345');
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('56b7c993-392f-41f8-adb1-9766842dc5fd', 'login2', 'AVALON123456');
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('a243b5f2-e265-4c25-82a9-dde4cc70643f', 'login3', 'Zxcvb123456');
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('51351bb1-7563-479d-a8e9-201d0ff934c2', 'login4', 'Sadly846612');
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('c792bbe6-2bf2-4fe0-a781-ba96bfeaa3b6', 'login5', 'Qwerty12345');
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
#include "../entities/user.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
class IAuthDAO
|
||||
{
|
||||
public:
|
||||
virtual std::string Login(
|
||||
const std::string& registrated_user_uuid,
|
||||
const std::string& auth_token) = 0;
|
||||
|
||||
virtual bool HasAuthorized(const std::string& auth_token) = 0;
|
||||
|
||||
virtual bool Logout(const std::string& user_token) = 0;
|
||||
|
||||
virtual ~IAuthDAO() = default;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
|
||||
#include "../entities/user.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
class IUserDAO
|
||||
{
|
||||
public:
|
||||
virtual std::string Create(const user& created_user) = 0;
|
||||
|
||||
virtual std::optional<user> GetByUUID(const std::string& uuid) = 0;
|
||||
|
||||
virtual std::optional<user> GetByLogin(const std::string& login) = 0;
|
||||
|
||||
virtual std::pair<bool, std::vector<user>> GetAll(size_t limit, size_t offset) = 0;
|
||||
|
||||
virtual bool Update(const user& u) = 0;
|
||||
|
||||
virtual bool Delete(const std::string& uuid) = 0;
|
||||
|
||||
virtual ~IUserDAO() = default;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#include <boost/uuid.hpp>
|
||||
|
||||
#include "MemoryAuthDAO.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace uad
|
||||
{
|
||||
MemoryAuthDAO::MemoryAuthDAO(mysqlx::Session& session): session_(session)
|
||||
{
|
||||
}
|
||||
|
||||
std::string MemoryAuthDAO::Login(
|
||||
const std::string& registrated_user_uuid,
|
||||
const std::string& auth_token)
|
||||
{
|
||||
users_uuids_to_auth_tokens_[registrated_user_uuid] = auth_token;
|
||||
auth_tokens_to_users_uuids_[auth_token] = registrated_user_uuid;
|
||||
|
||||
return auth_token;
|
||||
}
|
||||
|
||||
bool MemoryAuthDAO::HasAuthorized(const std::string& auth_token)
|
||||
{
|
||||
return auth_tokens_to_users_uuids_.count(auth_token) > 0;
|
||||
}
|
||||
|
||||
bool MemoryAuthDAO::Logout(const std::string& auth_token)
|
||||
{
|
||||
if (!HasAuthorized(auth_token)) return false;
|
||||
|
||||
string user_uuid = auth_tokens_to_users_uuids_[auth_token];
|
||||
|
||||
users_uuids_to_auth_tokens_.erase(user_uuid);
|
||||
auth_tokens_to_users_uuids_.erase(auth_token);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <mysqlx/xdevapi.h>
|
||||
|
||||
#include "IAuthDAO.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
class MemoryAuthDAO : public uad::IAuthDAO
|
||||
{
|
||||
std::unordered_map<std::string, std::string> users_uuids_to_auth_tokens_;
|
||||
std::unordered_map<std::string, std::string> auth_tokens_to_users_uuids_;
|
||||
|
||||
mysqlx::Session& session_;
|
||||
public:
|
||||
explicit MemoryAuthDAO(mysqlx::Session& session);
|
||||
|
||||
std::string Login(
|
||||
const std::string& registrated_user_uuid,
|
||||
const std::string& auth_token) override;
|
||||
|
||||
bool HasAuthorized(const std::string& auth_token) override;
|
||||
|
||||
bool Logout(const std::string& auth_token) override;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
#include <boost/uuid.hpp>
|
||||
|
||||
#include "MySQLUserDAO.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace string_literals;
|
||||
|
||||
namespace uad
|
||||
{
|
||||
MySQLUserDAO::MySQLUserDAO(mysqlx::Session& session) :
|
||||
session_(session)
|
||||
{
|
||||
}
|
||||
|
||||
string MySQLUserDAO::Create(const user& created_user)
|
||||
{
|
||||
boost::uuids::random_generator generator;
|
||||
boost::uuids::uuid uuid = generator();
|
||||
const std::string uuid_str = boost::uuids::to_string(uuid);
|
||||
|
||||
|
||||
static const string sql_script =
|
||||
"INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES (?, ?, ?);"s;
|
||||
|
||||
session_.
|
||||
sql(sql_script)
|
||||
.bind(uuid_str, created_user.login, created_user.hashed_password).execute();
|
||||
|
||||
return uuid_str;
|
||||
}
|
||||
|
||||
optional<user> MySQLUserDAO::GetByUUID(const string& uuid)
|
||||
{
|
||||
static const string sql_script = "SELECT * FROM `up_and_down`.`users` WHERE (uuid = ?) LIMIT 1;"s;
|
||||
mysqlx::SqlResult sql_result = session_.
|
||||
sql(sql_script)
|
||||
.bind(uuid)
|
||||
.execute();
|
||||
|
||||
return GetSingleUserBySQLResult(std::move(sql_result));
|
||||
}
|
||||
|
||||
optional<user> MySQLUserDAO::GetByLogin(const string& login)
|
||||
{
|
||||
static const std::string sql_script = "SELECT * FROM `up_and_down`.`users` WHERE (login = ?) LIMIT 1;"s;
|
||||
mysqlx::SqlResult sql_result = session_.
|
||||
sql(sql_script)
|
||||
.bind(login)
|
||||
.execute();
|
||||
|
||||
return GetSingleUserBySQLResult(std::move(sql_result));
|
||||
}
|
||||
|
||||
pair<bool, vector<user>> MySQLUserDAO::GetAll(size_t limit, size_t offset)
|
||||
{
|
||||
static const string sql_script = "SELECT * FROM `up_and_down`.`users` LIMIT ? OFFSET ?;"s;
|
||||
|
||||
mysqlx::SqlResult sql_result = session_
|
||||
.sql(sql_script)
|
||||
.bind(limit, offset)
|
||||
.execute();
|
||||
list<mysqlx::Row> rows = sql_result.fetchAll();
|
||||
pair<bool, vector<user>> ret;
|
||||
|
||||
if (!rows.size())
|
||||
{
|
||||
ret.first = true;
|
||||
ret.second = vector<user>{};
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret.first = rows.size() < limit + 1;
|
||||
ret.second = vector<user>{};
|
||||
|
||||
ret.second.reserve(limit);
|
||||
|
||||
for (const auto& row : rows)
|
||||
{
|
||||
if (!limit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
user user;
|
||||
|
||||
const string user_uuid = row[0].get<string>();
|
||||
const string user_login = row[1].get<string>();
|
||||
|
||||
ret.second.push_back({.uuid = user_uuid, .login = user_login});
|
||||
--limit;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool MySQLUserDAO::Update(const user& u)
|
||||
{
|
||||
static const string sql_script = "UPDATE `up_and_down`.`users` SET `login` = ? WHERE `uuid` = ?;"s;
|
||||
|
||||
auto schema = session_.sql(sql_script)
|
||||
.bind(u.login, u.uuid)
|
||||
.execute();
|
||||
|
||||
return !!schema.getAffectedItemsCount();
|
||||
}
|
||||
|
||||
bool MySQLUserDAO::Delete(const string& uuid)
|
||||
{
|
||||
static const string sql_script = "DELETE FROM `up_and_down`.`users` WHERE `uuid` = ?;";
|
||||
|
||||
auto schema = session_.sql(sql_script)
|
||||
.bind(uuid)
|
||||
.execute();
|
||||
|
||||
return !!schema.getAffectedItemsCount();
|
||||
}
|
||||
|
||||
std::optional<user> MySQLUserDAO::GetSingleUserBySQLResult(mysqlx::SqlResult&& sql_result)
|
||||
{
|
||||
list<mysqlx::Row> rows = sql_result.fetchAll();
|
||||
|
||||
if (!rows.size())
|
||||
{
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
auto row_data = *rows.begin();
|
||||
|
||||
const string user_uuid = row_data[0].get<string>();
|
||||
const string user_login = row_data[1].get<string>();
|
||||
const string user_hashed_password = row_data[2].get<string>();
|
||||
|
||||
return optional<user>({
|
||||
.uuid = user_uuid,
|
||||
.login = user_login,
|
||||
.hashed_password = user_hashed_password
|
||||
});
|
||||
}
|
||||
} // uad
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <mysqlx/xdevapi.h>
|
||||
|
||||
#include "IUserDAO.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
class MySQLUserDAO : public IUserDAO
|
||||
{
|
||||
mysqlx::Session& session_;
|
||||
public:
|
||||
explicit MySQLUserDAO(mysqlx::Session& session);
|
||||
|
||||
std::string Create(const user& created_user) override;
|
||||
|
||||
std::optional<user> GetByUUID(const std::string& uuid) override;
|
||||
|
||||
std::optional<user> GetByLogin(const std::string& login) override;
|
||||
|
||||
std::pair<bool, std::vector<user>> GetAll(size_t limit, size_t offset) override;
|
||||
|
||||
bool Update(const user& u) override;
|
||||
|
||||
bool Delete(const std::string& uuid) override;
|
||||
|
||||
private:
|
||||
std::optional<user> GetSingleUserBySQLResult(mysqlx::SqlResult&& sql_result);
|
||||
};
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
#include "Listener.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
Listener::Listener(boost::asio::io_context& ioc,
|
||||
boost::asio::ip::tcp::endpoint endpoint,
|
||||
const std::shared_ptr<const std::string>& doc_root)
|
||||
: ioc_(ioc), acceptor_(net::make_strand(ioc)), doc_root_(doc_root)
|
||||
{
|
||||
beast::error_code ec;
|
||||
|
||||
acceptor_.open(endpoint.protocol(), ec);
|
||||
if (ec)
|
||||
{
|
||||
uad::Fail(ec, "open");
|
||||
return;
|
||||
}
|
||||
|
||||
acceptor_.set_option(net::socket_base::reuse_address(true), ec);
|
||||
if (ec)
|
||||
{
|
||||
uad::Fail(ec, "set_option");
|
||||
return;
|
||||
}
|
||||
|
||||
acceptor_.bind(endpoint, ec);
|
||||
if (ec)
|
||||
{
|
||||
uad::Fail(ec, "bind");
|
||||
return;
|
||||
}
|
||||
|
||||
acceptor_.listen(
|
||||
net::socket_base::max_listen_connections, ec);
|
||||
if (ec)
|
||||
{
|
||||
uad::Fail(ec, "listen");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Listener::Run()
|
||||
{
|
||||
DoAccept();
|
||||
}
|
||||
|
||||
void Listener::DoAccept()
|
||||
{
|
||||
acceptor_.async_accept(
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&Listener::OnAccept,
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void Listener::OnAccept(beast::error_code ec, tcp::socket socket)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
uad::Fail(ec, "accept");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::make_shared<uad::Session>(
|
||||
std::move(socket),
|
||||
doc_root_)->Run();
|
||||
}
|
||||
|
||||
DoAccept();
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/version.hpp>
|
||||
#include <boost/asio/dispatch.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "helpers.h"
|
||||
#include "Session.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
namespace beast = boost::beast;
|
||||
namespace http = beast::http;
|
||||
namespace net = boost::asio;
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
|
||||
class Listener : public std::enable_shared_from_this<Listener>
|
||||
{
|
||||
net::io_context& ioc_;
|
||||
tcp::acceptor acceptor_;
|
||||
std::shared_ptr<std::string const> doc_root_;
|
||||
|
||||
public:
|
||||
Listener(
|
||||
net::io_context& ioc,
|
||||
tcp::endpoint endpoint,
|
||||
std::shared_ptr<std::string const> const& doc_root);
|
||||
|
||||
void Run();
|
||||
|
||||
private:
|
||||
void DoAccept();
|
||||
|
||||
void OnAccept(beast::error_code ec, tcp::socket socket);
|
||||
};
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
#include "BasicRequestHandler.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
|
||||
#include "../content_type.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace string_view_literals;
|
||||
|
||||
namespace uad
|
||||
{
|
||||
namespace beast = boost::beast;
|
||||
namespace http = beast::http;
|
||||
namespace net = boost::asio;
|
||||
|
||||
http::message_generator HandleRequest(
|
||||
beast::string_view doc_root,
|
||||
http::request<http::string_body>&& req)
|
||||
{
|
||||
auto const bad_request =
|
||||
[&req](beast::string_view why)
|
||||
{
|
||||
http::response<http::string_body> res {http::status::bad_request, req.version()};
|
||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(http::field::content_type, "text/html");
|
||||
res.keep_alive(req.keep_alive());
|
||||
res.body() = std::string(why);
|
||||
res.prepare_payload();
|
||||
return res;
|
||||
};
|
||||
|
||||
auto const not_found =
|
||||
[&req](beast::string_view target)
|
||||
{
|
||||
http::response<http::string_body> res {http::status::not_found, req.version()};
|
||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(http::field::content_type, "text/html");
|
||||
res.keep_alive(req.keep_alive());
|
||||
res.body() = "The resource '" + std::string(target) + "' was not found.";
|
||||
res.prepare_payload();
|
||||
return res;
|
||||
};
|
||||
|
||||
auto const server_error =
|
||||
[&req](beast::string_view what)
|
||||
{
|
||||
http::response<http::string_body> res {http::status::internal_server_error, req.version()};
|
||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(http::field::content_type, "text/html");
|
||||
res.keep_alive(req.keep_alive());
|
||||
res.body() = "An error occurred: '" + std::string(what) + "'";
|
||||
res.prepare_payload();
|
||||
return res;
|
||||
};
|
||||
|
||||
if (req.target() == "/HelloWorld"sv)
|
||||
{
|
||||
http::response<http::string_body> res {};
|
||||
res.body() = "{ \"Hello\": \"World\" }"sv;
|
||||
res.content_length(res.body().size());
|
||||
res.set(http::field::content_type, content_type::k_JSON);
|
||||
res.prepare_payload();
|
||||
res.keep_alive(req.keep_alive());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
if (req.method() != http::verb::get &&
|
||||
req.method() != http::verb::head)
|
||||
return bad_request("Unknown HTTP-method");
|
||||
|
||||
if (req.target().empty() ||
|
||||
req.target()[0] != '/' ||
|
||||
req.target().find("..") != beast::string_view::npos)
|
||||
return bad_request("Illegal request-target");
|
||||
|
||||
std::string path = PathCat(doc_root, req.target());
|
||||
if (req.target().back() == '/')
|
||||
path.append("index.html");
|
||||
|
||||
beast::error_code ec;
|
||||
http::file_body::value_type body;
|
||||
body.open(path.c_str(), beast::file_mode::scan, ec);
|
||||
|
||||
if (ec == beast::errc::no_such_file_or_directory)
|
||||
return not_found(req.target());
|
||||
|
||||
if (ec)
|
||||
return server_error(ec.message());
|
||||
|
||||
auto const size = body.size();
|
||||
|
||||
if (req.method() == http::verb::head)
|
||||
{
|
||||
http::response<http::empty_body> res {http::status::ok, req.version()};
|
||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(http::field::content_type, MimeType(path));
|
||||
res.content_length(size);
|
||||
res.keep_alive(req.keep_alive());
|
||||
return res;
|
||||
}
|
||||
|
||||
http::response<http::file_body> res {
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(std::move(body)),
|
||||
std::make_tuple(http::status::ok, req.version())};
|
||||
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(http::field::content_type, MimeType(path));
|
||||
res.content_length(size);
|
||||
res.keep_alive(req.keep_alive());
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/version.hpp>
|
||||
#include <boost/asio/dispatch.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
|
||||
#include "./../helpers.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
namespace beast = boost::beast;
|
||||
namespace http = beast::http;
|
||||
namespace net = boost::asio;
|
||||
|
||||
http::message_generator HandleRequest(
|
||||
beast::string_view doc_root,
|
||||
http::request<http::string_body>&& req);
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
#include "RequestHandlers/BasicRequestHandler.h"
|
||||
#include "Session.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
Session::Session(
|
||||
tcp::socket&& socket,
|
||||
std::shared_ptr<std::string const> const& doc_root)
|
||||
: stream_(std::move(socket)), doc_root_(doc_root) {}
|
||||
|
||||
void Session::Run()
|
||||
{
|
||||
net::dispatch(stream_.get_executor(),
|
||||
beast::bind_front_handler(
|
||||
&Session::DoRead,
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void Session::DoRead()
|
||||
{
|
||||
req_ = {};
|
||||
|
||||
stream_.expires_after(std::chrono::seconds(30));
|
||||
|
||||
http::async_read(stream_, buffer_, req_,
|
||||
beast::bind_front_handler(
|
||||
&Session::OnRead,
|
||||
shared_from_this()));
|
||||
}
|
||||
|
||||
void Session::OnRead(
|
||||
beast::error_code ec,
|
||||
std::size_t bytes_transferred)
|
||||
{
|
||||
boost::ignore_unused(bytes_transferred);
|
||||
|
||||
if (ec == http::error::end_of_stream)
|
||||
return DoClose();
|
||||
|
||||
if (ec)
|
||||
return Fail(ec, "read");
|
||||
|
||||
SendResponse(
|
||||
HandleRequest(*doc_root_, std::move(req_)));
|
||||
}
|
||||
|
||||
void Session::SendResponse(http::message_generator&& msg)
|
||||
{
|
||||
bool keep_alive = msg.keep_alive();
|
||||
|
||||
beast::async_write(
|
||||
stream_,
|
||||
std::move(msg),
|
||||
beast::bind_front_handler(
|
||||
&Session::OnWrite, shared_from_this(), keep_alive));
|
||||
}
|
||||
|
||||
void Session::OnWrite(
|
||||
bool keep_alive,
|
||||
beast::error_code ec,
|
||||
std::size_t bytes_transferred)
|
||||
{
|
||||
boost::ignore_unused(bytes_transferred);
|
||||
|
||||
if (ec)
|
||||
return uad::Fail(ec, "write");
|
||||
|
||||
if (!keep_alive)
|
||||
{
|
||||
return DoClose();
|
||||
}
|
||||
|
||||
DoRead();
|
||||
}
|
||||
|
||||
void Session::DoClose()
|
||||
{
|
||||
beast::error_code ec;
|
||||
stream_.socket().shutdown(tcp::socket::shutdown_send, ec);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/version.hpp>
|
||||
#include <boost/asio/dispatch.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
namespace beast = boost::beast;
|
||||
namespace http = beast::http;
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
namespace net = boost::asio;
|
||||
|
||||
class Session : public std::enable_shared_from_this<Session>
|
||||
{
|
||||
beast::tcp_stream stream_;
|
||||
beast::flat_buffer buffer_;
|
||||
std::shared_ptr<std::string const> doc_root_;
|
||||
http::request<http::string_body> req_;
|
||||
|
||||
public:
|
||||
Session(
|
||||
tcp::socket&& socket,
|
||||
std::shared_ptr<std::string const> const& doc_root);
|
||||
|
||||
void Run();
|
||||
|
||||
void DoRead();
|
||||
|
||||
void OnRead(
|
||||
beast::error_code ec,
|
||||
std::size_t bytes_transferred);
|
||||
|
||||
void SendResponse(http::message_generator&& msg);
|
||||
|
||||
void OnWrite(
|
||||
bool keep_alive,
|
||||
beast::error_code ec,
|
||||
std::size_t bytes_transferred);
|
||||
|
||||
void DoClose();
|
||||
};
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#include <string_view>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
struct content_type
|
||||
{
|
||||
content_type() = delete;
|
||||
constexpr inline static std::string_view k_TextHtml = "text/html"sv;
|
||||
constexpr inline static std::string_view k_TextCsv = "text/csv"sv;
|
||||
constexpr inline static std::string_view k_TextPlain = "text/plain"sv;
|
||||
constexpr inline static std::string_view k_JSON = "application/json"sv;
|
||||
constexpr inline static std::string_view k_Audio = "audio/mpeg"sv;
|
||||
constexpr inline static std::string_view k_AudioExample = "audio/example"sv;
|
||||
constexpr inline static std::string_view k_FontWoff = "font/woff"sv;
|
||||
constexpr inline static std::string_view k_FontTtf = "font/ttf"sv;
|
||||
constexpr inline static std::string_view k_FontOtf = "font/otf"sv;
|
||||
constexpr inline static std::string_view k_ImagePng = "image/png"sv;
|
||||
constexpr inline static std::string_view k_ImageJpeg = "image/jpeg"sv;
|
||||
constexpr inline static std::string_view k_ImageGif = "image/gif"sv;
|
||||
constexpr inline static std::string_view k_Model = "model/vrml"sv;
|
||||
constexpr inline static std::string_view k_VideoMp4 = "video/mp4"sv;
|
||||
constexpr inline static std::string_view k_VideoWebm = "video/webm"sv;
|
||||
constexpr inline static std::string_view k_Binary = "application/octet-stream"sv;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <string>
|
||||
|
||||
#include "mysql_connector.h"
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
namespace uad
|
||||
{
|
||||
static mysqlx::Session* mysql_session = nullptr;
|
||||
|
||||
void SetMySqlSession(mysqlx::Session* ptr)
|
||||
{
|
||||
mysql_session = ptr;
|
||||
}
|
||||
|
||||
mysqlx::Session& GetMySqlSession()
|
||||
{
|
||||
return *mysql_session;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <mysqlx/xdevapi.h>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
void SetMySqlSession(mysqlx::Session* ptr);
|
||||
|
||||
mysqlx::Session& GetMySqlSession();
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include <regex>
|
||||
#include <boost/json.hpp>
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <mysqlx/common/api.h>
|
||||
#include <boost/uuid.hpp>
|
||||
|
||||
#include "IExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
#include "../DAO/IAuthDAO.h"
|
||||
#include "../helpers/helpers.h"
|
||||
#include "../exceptions/session_exception.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
template <class Body, class Allocator, class ResponseType>
|
||||
class AuthLoginExecutor : public IExecutor<Body, Allocator, ResponseType>
|
||||
{
|
||||
mysqlx::Session& session_;
|
||||
const std::shared_ptr<IUserDAO>& user_dao_;
|
||||
const std::shared_ptr<IAuthDAO>& auth_dao_;
|
||||
|
||||
public:
|
||||
AuthLoginExecutor(mysqlx::Session& session,
|
||||
const std::shared_ptr<IUserDAO>& user_dao,
|
||||
const std::shared_ptr<IAuthDAO>& auth_dao)
|
||||
: session_(session), user_dao_(user_dao), auth_dao_(auth_dao)
|
||||
{
|
||||
}
|
||||
|
||||
boost::beast::http::response<ResponseType> operator ()(
|
||||
boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req
|
||||
) override
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::json;
|
||||
using namespace boost::beast;
|
||||
using namespace std::string_literals;
|
||||
|
||||
const auto body = req.body();
|
||||
value req_json;
|
||||
|
||||
try
|
||||
{
|
||||
req_json = json::parse(body);
|
||||
}
|
||||
catch (const system::system_error& err)
|
||||
{
|
||||
throw session_exception(http::status::bad_request, "cannot deserialize json");
|
||||
}
|
||||
|
||||
|
||||
const std::string login = req_json.as_object().at("login").as_string().c_str();
|
||||
const std::string password = req_json.as_object().at("password").as_string().c_str();
|
||||
|
||||
if (login.empty() || password.empty())
|
||||
{
|
||||
throw session_exception(http::status::unprocessable_entity, "Login or password are empty"s);
|
||||
}
|
||||
|
||||
const std::optional<user> maybe_user = user_dao_->GetByLogin(login);
|
||||
|
||||
if (!maybe_user.has_value() && maybe_user.value().hashed_password != HashPassword(password))
|
||||
{
|
||||
throw session_exception(http::status::forbidden,"Incorrect login or password");
|
||||
}
|
||||
const std::string token = GenerateUUID();
|
||||
auth_dao_->Login(maybe_user.value().uuid, token);
|
||||
|
||||
http::response<ResponseType> res{http::status::ok, req.version()};
|
||||
value response_body;
|
||||
|
||||
response_body.emplace_object();
|
||||
response_body.as_object().emplace("token", token);
|
||||
|
||||
res.body() = serialize(response_body);
|
||||
res.set(http::field::content_type, "application/json");
|
||||
res.content_length(res.body().size());
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <regex>
|
||||
#include <boost/json.hpp>
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <mysqlx/common/api.h>
|
||||
#include <boost/uuid.hpp>
|
||||
|
||||
#include "IExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
#include "../DAO/IAuthDAO.h"
|
||||
#include "../helpers/helpers.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
template <class Body, class Allocator, class ResponseType>
|
||||
class AuthLogoutExecutor : public IExecutor<Body, Allocator, ResponseType>
|
||||
{
|
||||
mysqlx::Session& session_;
|
||||
const std::shared_ptr<IAuthDAO>& auth_dao_;
|
||||
|
||||
public:
|
||||
AuthLogoutExecutor(mysqlx::Session& session,
|
||||
const std::shared_ptr<IAuthDAO>& auth_dao) :
|
||||
session_(session), auth_dao_(auth_dao)
|
||||
{
|
||||
}
|
||||
|
||||
boost::beast::http::response<ResponseType> operator ()(
|
||||
boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req
|
||||
) override
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::json;
|
||||
using namespace boost::beast;
|
||||
using namespace std::string_literals;
|
||||
|
||||
const auto body = req.body();
|
||||
value req_json;
|
||||
|
||||
try
|
||||
{
|
||||
req_json = json::parse(body);
|
||||
}
|
||||
catch (const system::system_error& err)
|
||||
{
|
||||
throw session_exception(http::status::internal_server_error, "cannot deserialize json"s);
|
||||
}
|
||||
|
||||
const std::string token = req_json.as_object().at("token").as_string().c_str();
|
||||
|
||||
if (!auth_dao_->Logout(token))
|
||||
{
|
||||
throw session_exception(http::status::bad_request, "token is not authorized"s);
|
||||
}
|
||||
|
||||
http::response<ResponseType> res{http::status::ok, req.version()};
|
||||
|
||||
res.body() = "null"s;
|
||||
res.set(http::field::content_type, "application/json");
|
||||
res.content_length(res.body().size());
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
#pragma once
|
||||
|
||||
#include <regex>
|
||||
#include <boost/json.hpp>
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "IExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
#include "../exceptions/session_exception.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
template <class Body, class Allocator, class ResponseType>
|
||||
class AuthRegistrationExecutor : public IExecutor<Body, Allocator, ResponseType>
|
||||
{
|
||||
mysqlx::Session& session_;
|
||||
const std::shared_ptr<IUserDAO>& user_dao_;
|
||||
|
||||
public:
|
||||
AuthRegistrationExecutor(mysqlx::Session& session,
|
||||
const std::shared_ptr<IUserDAO>& user_dao)
|
||||
: session_(session), user_dao_(user_dao)
|
||||
{
|
||||
}
|
||||
|
||||
boost::beast::http::response<ResponseType> operator ()(
|
||||
boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req
|
||||
) override
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::json;
|
||||
using namespace boost::beast;
|
||||
using namespace std::string_literals;
|
||||
|
||||
const auto& body = req.body();
|
||||
value req_json;
|
||||
|
||||
try
|
||||
{
|
||||
req_json = json::parse(body);
|
||||
}
|
||||
catch (const system::system_error& err)
|
||||
{
|
||||
throw session_exception(http::status::bad_request, "cannot deserialize json");
|
||||
}
|
||||
|
||||
const std::string login = req_json.as_object().at("login").as_string().c_str();
|
||||
const std::string password = req_json.as_object().at("password").as_string().c_str();
|
||||
|
||||
if (!ValidateLogin(login) || !ValidatePassword(password))
|
||||
{
|
||||
throw session_exception(
|
||||
http::status::unprocessable_entity,
|
||||
"Validations failed. Login should have length from 3 to 50. Password from 5 characters length."s
|
||||
);
|
||||
}
|
||||
|
||||
if (user_dao_->GetByLogin(login).has_value())
|
||||
{
|
||||
throw session_exception(http::status::conflict, "user with login "s + login + " exists"s);
|
||||
}
|
||||
|
||||
user user;
|
||||
|
||||
user.login = login;
|
||||
user.hashed_password = HashPassword(password);
|
||||
|
||||
const std::string uuid_stringified = user_dao_->Create(user);
|
||||
|
||||
http::response<ResponseType> res{
|
||||
http::status::created, req.version()
|
||||
};
|
||||
value response_body;
|
||||
|
||||
response_body.emplace_object();
|
||||
|
||||
response_body.as_object().emplace(
|
||||
"uuid",
|
||||
uuid_stringified
|
||||
);
|
||||
response_body.as_object().emplace(
|
||||
"login",
|
||||
user.login
|
||||
);
|
||||
|
||||
res.body() = serialize(response_body);
|
||||
res.set(http::field::content_type, "application/json");
|
||||
res.content_length(res.body().size());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
bool ValidateLogin(const std::string& login)
|
||||
{
|
||||
if (login.size() < 3 || login.size() > 50) return false;
|
||||
|
||||
std::regex pattern(std::string("^[A-Za-z0-9_]+$"));
|
||||
|
||||
return std::regex_match(login, pattern);
|
||||
}
|
||||
|
||||
bool ValidatePassword(const std::string& password)
|
||||
{
|
||||
return password.size() >= 5;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast.hpp>
|
||||
|
||||
#include "./IController.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
template <class Body, class Allocator, class ResponseType>
|
||||
class Controller : public IController<Body, Allocator, ResponseType>
|
||||
{
|
||||
public:
|
||||
using HTTPMethodsToExecutors = std::unordered_map<boost::beast::http::verb, std::shared_ptr<IExecutor<Body, Allocator, ResponseType>>>;
|
||||
|
||||
private:
|
||||
HTTPMethodsToExecutors executors_;
|
||||
public:
|
||||
Controller() = default;
|
||||
|
||||
explicit Controller(HTTPMethodsToExecutors&& executors): executors_(std::move(executors)) {}
|
||||
|
||||
std::optional<std::shared_ptr<IExecutor<Body, Allocator, ResponseType>>> FindExecutor(
|
||||
boost::beast::http::verb method
|
||||
) override
|
||||
{
|
||||
if (!executors_.count(method)) return std::nullopt;
|
||||
|
||||
return std::make_optional(executors_.at(method));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast.hpp>
|
||||
|
||||
#include "../db/mysql_connector.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
#include "AuthRegistrationExecutor.h"
|
||||
#include "RootExecutor.h"
|
||||
#include "../DAO/MemoryAuthDAO.h"
|
||||
#include "../DAO/MySQLUserDAO.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
template <class Body, class Allocator, class Send>
|
||||
void HandleRequest(
|
||||
boost::beast::string_view doc_root,
|
||||
boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req,
|
||||
Send&& send)
|
||||
{
|
||||
static std::shared_ptr<IUserDAO> user_dao = std::make_shared<MySQLUserDAO>(GetMySqlSession());
|
||||
static std::shared_ptr<IAuthDAO> auth_dao = std::make_shared<MemoryAuthDAO>(GetMySqlSession());
|
||||
|
||||
static RootExecutor<Body, Allocator, boost::beast::http::string_body, Send> root_executor(
|
||||
GetMySqlSession(),
|
||||
user_dao,
|
||||
auth_dao
|
||||
);
|
||||
|
||||
root_executor(doc_root, std::move(req), std::forward<Send>(send));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast.hpp>
|
||||
|
||||
#include "IExecutor.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
template <class Body, class Allocator, class ResponseType>
|
||||
class IController
|
||||
{
|
||||
public:
|
||||
virtual std::optional<std::shared_ptr<IExecutor<Body, Allocator, ResponseType>>> FindExecutor(
|
||||
boost::beast::http::verb method
|
||||
) = 0;
|
||||
virtual ~IController() = default;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast.hpp>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
template <class Body, class Allocator, class ResponseType>
|
||||
class IExecutor
|
||||
{
|
||||
public:
|
||||
virtual boost::beast::http::response<ResponseType> operator ()(
|
||||
boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>&& req
|
||||
) = 0;
|
||||
virtual ~IExecutor() = default;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <mysqlx/common/api.h>
|
||||
|
||||
#include "IExecutor.h"
|
||||
#include "IController.h"
|
||||
#include "Controller.h"
|
||||
#include "AuthRegistrationExecutor.h"
|
||||
#include "AuthLoginExecutor.h"
|
||||
#include "AuthLogoutExecutor.h"
|
||||
#include "../DAO/IUserDAO.h"
|
||||
#include "../DAO/IAuthDAO.h"
|
||||
#include "./../helpers/helpers.h"
|
||||
#include "./../exceptions/session_exception.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
template <class Body, class Allocator, class ResponseType, class Send>
|
||||
class RootExecutor
|
||||
{
|
||||
using IRouteExecutor = IExecutor<Body, Allocator, boost::beast::http::string_body>;
|
||||
using RouteAuthRegistrationExecutor = AuthRegistrationExecutor<
|
||||
Body, Allocator, boost::beast::http::string_body>;
|
||||
using RouteAuthLoginExecutor = AuthLoginExecutor<
|
||||
Body, Allocator, boost::beast::http::string_body>;
|
||||
using RouteAuthLogoutExecutor = AuthLogoutExecutor<
|
||||
Body, Allocator, boost::beast::http::string_body>;
|
||||
using IRouteController = IController<Body, Allocator, boost::beast::http::string_body>;
|
||||
using RouteController = Controller<Body, Allocator, boost::beast::http::string_body>;
|
||||
using RoutesPathes = std::unordered_map<std::string, std::unique_ptr<IRouteController>>;
|
||||
using Request = boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>>;
|
||||
using StringResponse = boost::beast::http::response<boost::beast::http::string_body>;
|
||||
using EmptyResponse = boost::beast::http::response<boost::beast::http::empty_body>;
|
||||
using FileResponse = boost::beast::http::response<boost::beast::http::file_body>;
|
||||
|
||||
private:
|
||||
RoutesPathes routes_pathes_;
|
||||
mysqlx::Session& session_;
|
||||
const std::shared_ptr<IUserDAO>& user_dao_;
|
||||
const std::shared_ptr<IAuthDAO>& auth_dao_;
|
||||
|
||||
public:
|
||||
RootExecutor(
|
||||
mysqlx::Session& session,
|
||||
const std::shared_ptr<IUserDAO>& user_dao,
|
||||
const std::shared_ptr<IAuthDAO>& auth_dao) :
|
||||
session_(session), user_dao_(user_dao), auth_dao_(auth_dao)
|
||||
{
|
||||
routes_pathes_["/api/v1/Auth/Register"] = std::make_unique<RouteController>(
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{boost::beast::http::verb::post, std::make_shared<RouteAuthRegistrationExecutor>(
|
||||
session_,
|
||||
user_dao_
|
||||
)}
|
||||
}
|
||||
);
|
||||
|
||||
routes_pathes_["/api/v1/Auth/Login"] = std::make_unique<RouteController>(
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{boost::beast::http::verb::post,
|
||||
std::make_shared<RouteAuthLoginExecutor>(session_, user_dao_, auth_dao_)}
|
||||
}
|
||||
);
|
||||
|
||||
routes_pathes_["/api/v1/Auth/Logout"] = std::make_unique<RouteController>(
|
||||
typename RouteController::HTTPMethodsToExecutors{
|
||||
{boost::beast::http::verb::post,
|
||||
std::make_shared<RouteAuthLogoutExecutor>(session_, auth_dao_)}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void operator ()(
|
||||
boost::beast::string_view doc_root,
|
||||
Request&& req,
|
||||
Send&& send
|
||||
)
|
||||
{
|
||||
const std::string& route = req.target();
|
||||
const bool is_match_route = routes_pathes_.count(route);
|
||||
|
||||
if (is_match_route)
|
||||
{
|
||||
std::optional<std::shared_ptr<IRouteExecutor>> maybe_executor_ptr = routes_pathes_
|
||||
.at(route)
|
||||
->FindExecutor(req.method());
|
||||
|
||||
if (maybe_executor_ptr.has_value())
|
||||
{
|
||||
IRouteExecutor& executor = *maybe_executor_ptr.value();
|
||||
|
||||
try
|
||||
{
|
||||
boost::beast::http::response<ResponseType> res = executor(std::move(req));
|
||||
|
||||
return send(std::move(res));
|
||||
}
|
||||
catch (const session_exception& e)
|
||||
{
|
||||
boost::beast::http::response<ResponseType> res{e.code, req.version()};
|
||||
boost::json::value response_body;
|
||||
|
||||
response_body.emplace_object();
|
||||
response_body.as_object().emplace("Result", e.what());
|
||||
|
||||
res.body() = serialize(response_body);
|
||||
res.set(boost::beast::http::field::content_type, "application/json");
|
||||
res.content_length(res.body().size());
|
||||
|
||||
return send(std::move(res));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (req.method() != boost::beast::http::verb::get &&
|
||||
req.method() != boost::beast::http::verb::head)
|
||||
return send(SendBadRequest(std::move(req), "Unknown boost::beast::HTTP-method"));
|
||||
|
||||
if (req.target().empty() || req.target()[0] != '/' ||
|
||||
req.target().find("..") != boost::beast::string_view::npos)
|
||||
return send(SendBadRequest(std::move(req), "Illegal request-target"));
|
||||
|
||||
std::string path = PathCat(doc_root, req.target());
|
||||
if (req.target().back() == '/')
|
||||
path.append("index.html");
|
||||
|
||||
boost::beast::error_code ec;
|
||||
boost::beast::http::file_body::value_type body;
|
||||
body.open(path.c_str(), boost::beast::file_mode::scan, ec);
|
||||
|
||||
if (ec == boost::beast::errc::no_such_file_or_directory)
|
||||
return send(SendNotFound(std::move(req), req.target()));
|
||||
|
||||
if (ec)
|
||||
return send(SendServerError(std::move(req), ec.message()));
|
||||
|
||||
auto const size = body.size();
|
||||
|
||||
if (req.method() == boost::beast::http::verb::head)
|
||||
{
|
||||
EmptyResponse res{
|
||||
boost::beast::http::status::ok,
|
||||
req.version()
|
||||
};
|
||||
res.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(boost::beast::http::field::content_type, MimeType(path));
|
||||
res.content_length(size);
|
||||
res.keep_alive(req.keep_alive());
|
||||
return send(std::move(res));
|
||||
}
|
||||
|
||||
FileResponse res{
|
||||
std::piecewise_construct, std::make_tuple(std::move(body)),
|
||||
std::make_tuple(boost::beast::http::status::ok, req.version())
|
||||
};
|
||||
res.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(boost::beast::http::field::content_type, MimeType(path));
|
||||
res.content_length(size);
|
||||
res.keep_alive(req.keep_alive());
|
||||
return send(std::move(res));
|
||||
}
|
||||
|
||||
private:
|
||||
StringResponse SendBadRequest(
|
||||
Request&& req,
|
||||
boost::beast::string_view why
|
||||
)
|
||||
{
|
||||
StringResponse res{
|
||||
boost::beast::http::status::bad_request, req.version()
|
||||
};
|
||||
res.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(boost::beast::http::field::content_type, "text/html");
|
||||
res.keep_alive(req.keep_alive());
|
||||
res.body() = std::string(why);
|
||||
res.prepare_payload();
|
||||
return res;
|
||||
}
|
||||
|
||||
StringResponse SendNotFound(
|
||||
Request&& req,
|
||||
boost::beast::string_view target
|
||||
)
|
||||
{
|
||||
StringResponse res{
|
||||
boost::beast::http::status::not_found, req.version()
|
||||
};
|
||||
res.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(boost::beast::http::field::content_type, "text/html");
|
||||
res.keep_alive(req.keep_alive());
|
||||
res.body() = "The resource '" + std::string(target) + "' was not found.";
|
||||
res.prepare_payload();
|
||||
return res;
|
||||
}
|
||||
|
||||
StringResponse SendServerError(
|
||||
Request&& req,
|
||||
boost::beast::string_view what
|
||||
)
|
||||
{
|
||||
StringResponse res{
|
||||
boost::beast::http::status::internal_server_error, req.version()
|
||||
};
|
||||
res.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||
res.set(boost::beast::http::field::content_type, "text/html");
|
||||
res.keep_alive(req.keep_alive());
|
||||
res.body() = "An error occurred: '" + std::string(what) + "'";
|
||||
res.prepare_payload();
|
||||
return res;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../helpers/helpers.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
struct user
|
||||
{
|
||||
std::string uuid;
|
||||
std::string login;
|
||||
std::string hashed_password;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "session_exception.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace uad
|
||||
{
|
||||
char const* session_exception::what() const
|
||||
{
|
||||
return message.c_str();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast/http/status.hpp>
|
||||
#include <string>
|
||||
#include <boost/exception/to_string.hpp>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
struct session_exception : std::exception
|
||||
{
|
||||
const boost::beast::http::status code;
|
||||
const std::string comment;
|
||||
const std::string message;
|
||||
|
||||
session_exception(const boost::beast::http::status ec, const std::string info)
|
||||
: code(ec), comment(info), message(std::to_string(static_cast<uint64_t>(ec)) + " - " + comment)
|
||||
{}
|
||||
char const* what() const override;
|
||||
};
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
#include "helpers.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
beast::string_view MimeType(beast::string_view path)
|
||||
{
|
||||
using beast::iequals;
|
||||
auto const ext = [&path]
|
||||
{
|
||||
auto const pos = path.rfind(".");
|
||||
if (pos == beast::string_view::npos)
|
||||
return beast::string_view {};
|
||||
return path.substr(pos);
|
||||
}();
|
||||
if (iequals(ext, ".htm")) return "text/html";
|
||||
if (iequals(ext, ".html")) return "text/html";
|
||||
if (iequals(ext, ".php")) return "text/html";
|
||||
if (iequals(ext, ".css")) return "text/css";
|
||||
if (iequals(ext, ".txt")) return "text/plain";
|
||||
if (iequals(ext, ".js")) return "application/javascript";
|
||||
if (iequals(ext, ".json")) return "application/json";
|
||||
if (iequals(ext, ".xml")) return "application/xml";
|
||||
if (iequals(ext, ".swf")) return "application/x-shockwave-flash";
|
||||
if (iequals(ext, ".flv")) return "video/x-flv";
|
||||
if (iequals(ext, ".png")) return "image/png";
|
||||
if (iequals(ext, ".jpe")) return "image/jpeg";
|
||||
if (iequals(ext, ".jpeg")) return "image/jpeg";
|
||||
if (iequals(ext, ".jpg")) return "image/jpeg";
|
||||
if (iequals(ext, ".gif")) return "image/gif";
|
||||
if (iequals(ext, ".bmp")) return "image/bmp";
|
||||
if (iequals(ext, ".ico")) return "image/vnd.microsoft.icon";
|
||||
if (iequals(ext, ".tiff")) return "image/tiff";
|
||||
if (iequals(ext, ".tif")) return "image/tiff";
|
||||
if (iequals(ext, ".svg")) return "image/svg+xml";
|
||||
if (iequals(ext, ".svgz")) return "image/svg+xml";
|
||||
return "application/text";
|
||||
}
|
||||
|
||||
std::string PathCat(
|
||||
beast::string_view base,
|
||||
beast::string_view path)
|
||||
{
|
||||
if (base.empty())
|
||||
return std::string(path);
|
||||
std::string result(base);
|
||||
#ifdef BOOST_MSVC
|
||||
char constexpr path_separator = '\\';
|
||||
if (result.back() == path_separator)
|
||||
result.resize(result.size() - 1);
|
||||
result.append(path.data(), path.size());
|
||||
for (auto& c: result)
|
||||
if (c == '/')
|
||||
c = path_separator;
|
||||
#else
|
||||
char constexpr path_separator = '/';
|
||||
if(result.back() == path_separator)
|
||||
result.resize(result.size() - 1);
|
||||
result.append(path.data(), path.size());
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
void Fail(beast::error_code ec, char const* what)
|
||||
{
|
||||
std::cerr << what << ": " << ec.message() << "\n";
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/version.hpp>
|
||||
#include <boost/asio/dispatch.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
namespace beast = boost::beast;
|
||||
namespace http = beast::http;
|
||||
namespace net = boost::asio;
|
||||
|
||||
beast::string_view MimeType(beast::string_view path);
|
||||
|
||||
std::string PathCat(beast::string_view base, beast::string_view path);
|
||||
|
||||
void Fail(beast::error_code ec, char const* what);
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <random>
|
||||
#include <boost/uuid.hpp>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
namespace uad
|
||||
{
|
||||
boost::beast::string_view MimeType(boost::beast::string_view path)
|
||||
{
|
||||
using boost::beast::iequals;
|
||||
auto const ext = [&path]
|
||||
{
|
||||
auto const pos = path.rfind(".");
|
||||
if (pos == boost::beast::string_view::npos)
|
||||
return boost::beast::string_view{};
|
||||
return path.substr(pos);
|
||||
}();
|
||||
if (iequals(ext, ".htm"))
|
||||
return "text/html";
|
||||
if (iequals(ext, ".html"))
|
||||
return "text/html";
|
||||
if (iequals(ext, ".php"))
|
||||
return "text/html";
|
||||
if (iequals(ext, ".css"))
|
||||
return "text/css";
|
||||
if (iequals(ext, ".txt"))
|
||||
return "text/plain";
|
||||
if (iequals(ext, ".js"))
|
||||
return "application/javascript";
|
||||
if (iequals(ext, ".json"))
|
||||
return "application/json";
|
||||
if (iequals(ext, ".xml"))
|
||||
return "application/xml";
|
||||
if (iequals(ext, ".swf"))
|
||||
return "application/x-shockwave-flash";
|
||||
if (iequals(ext, ".flv"))
|
||||
return "video/x-flv";
|
||||
if (iequals(ext, ".png"))
|
||||
return "image/png";
|
||||
if (iequals(ext, ".jpe"))
|
||||
return "image/jpeg";
|
||||
if (iequals(ext, ".jpeg"))
|
||||
return "image/jpeg";
|
||||
if (iequals(ext, ".jpg"))
|
||||
return "image/jpeg";
|
||||
if (iequals(ext, ".gif"))
|
||||
return "image/gif";
|
||||
if (iequals(ext, ".bmp"))
|
||||
return "image/bmp";
|
||||
if (iequals(ext, ".ico"))
|
||||
return "image/vnd.microsoft.icon";
|
||||
if (iequals(ext, ".tiff"))
|
||||
return "image/tiff";
|
||||
if (iequals(ext, ".tif"))
|
||||
return "image/tiff";
|
||||
if (iequals(ext, ".svg"))
|
||||
return "image/svg+xml";
|
||||
if (iequals(ext, ".svgz"))
|
||||
return "image/svg+xml";
|
||||
return "application/text";
|
||||
}
|
||||
|
||||
std::string PathCat(boost::beast::string_view base, boost::beast::string_view path)
|
||||
{
|
||||
if (base.empty())
|
||||
return std::string(path);
|
||||
std::string result(base);
|
||||
#ifdef BOOST_MSVC
|
||||
char constexpr path_separator = '\\';
|
||||
if (result.back() == path_separator)
|
||||
result.resize(result.size() - 1);
|
||||
result.append(path.data(), path.size());
|
||||
for (auto& c : result)
|
||||
if (c == '/')
|
||||
c = path_separator;
|
||||
#else
|
||||
char constexpr path_separator = '/';
|
||||
if (result.back() == path_separator)
|
||||
result.resize(result.size() - 1);
|
||||
result.append(path.data(), path.size());
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
void Fail(boost::beast::error_code ec, char const* what)
|
||||
{
|
||||
std::cerr << what << ": " << ec.message() << "\n";
|
||||
}
|
||||
|
||||
|
||||
std::string ToHex(std::byte* src, size_t len)
|
||||
{
|
||||
if (!src || !len) return "";
|
||||
|
||||
string ret;
|
||||
ret.reserve(len * 2);
|
||||
boost::format formatter = boost::format("%02X");
|
||||
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
{
|
||||
byte target_byte = src[i];
|
||||
|
||||
formatter % static_cast<int32_t>(target_byte);
|
||||
ret += formatter.str();
|
||||
|
||||
formatter.clear();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string HashPassword(const std::string& password)
|
||||
{
|
||||
size_t calculated_hash = std::hash<string>{}(password);
|
||||
return ToHex((byte*)&calculated_hash, sizeof(calculated_hash));
|
||||
}
|
||||
|
||||
std::string GenerateUUID()
|
||||
{
|
||||
uuids::random_generator generator;
|
||||
|
||||
return uuids::to_string(generator());
|
||||
}
|
||||
|
||||
uint64_t Random()
|
||||
{
|
||||
std::random_device device;
|
||||
std::mt19937_64 random_generator(device());
|
||||
std::uniform_int_distribution<std::mt19937_64::result_type> dist(0,UINT64_MAX);
|
||||
|
||||
return dist(random_generator);
|
||||
}
|
||||
} // namespace uad
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast.hpp>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
boost::beast::string_view MimeType(boost::beast::string_view path);
|
||||
|
||||
std::string PathCat(boost::beast::string_view base, boost::beast::string_view path);
|
||||
|
||||
void Fail(boost::beast::error_code ec, char const* what);
|
||||
|
||||
std::string ToHex(std::byte* src, size_t len);
|
||||
|
||||
std::string HashPassword(const std::string& password);
|
||||
|
||||
std::string GenerateUUID();
|
||||
|
||||
uint64_t Random();
|
||||
} // namespace uad
|
||||
@@ -0,0 +1,71 @@
|
||||
#include <boost/asio/strand.hpp>
|
||||
|
||||
#include "Listener.h"
|
||||
|
||||
#include "./../helpers/helpers.h"
|
||||
#include "./../session/HttpSession.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
Listener::Listener(boost::asio::io_context& ioc, boost::asio::ip::tcp::endpoint endpoint,
|
||||
std::shared_ptr<std::string const> const& doc_root) :
|
||||
ioc_(ioc), acceptor_(boost::asio::make_strand(ioc)), doc_root_(doc_root)
|
||||
{
|
||||
boost::beast::error_code ec;
|
||||
|
||||
acceptor_.open(endpoint.protocol(), ec);
|
||||
if (ec)
|
||||
{
|
||||
Fail(ec, "open");
|
||||
return;
|
||||
}
|
||||
|
||||
acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec);
|
||||
if (ec)
|
||||
{
|
||||
Fail(ec, "set_option");
|
||||
return;
|
||||
}
|
||||
|
||||
acceptor_.bind(endpoint, ec);
|
||||
if (ec)
|
||||
{
|
||||
Fail(ec, "bind");
|
||||
return;
|
||||
}
|
||||
|
||||
acceptor_.listen(boost::asio::socket_base::max_listen_connections, ec);
|
||||
if (ec)
|
||||
{
|
||||
Fail(ec, "listen");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Listener::Run()
|
||||
{
|
||||
boost::asio::dispatch(
|
||||
acceptor_.get_executor(),
|
||||
boost::beast::bind_front_handler(&Listener::DoAccept, this->shared_from_this()));
|
||||
}
|
||||
|
||||
void Listener::DoAccept()
|
||||
{
|
||||
acceptor_.async_accept(boost::asio::make_strand(ioc_),
|
||||
boost::beast::bind_front_handler(&Listener::OnAccept, shared_from_this()));
|
||||
}
|
||||
|
||||
void Listener::OnAccept(boost::beast::error_code ec, boost::asio::ip::tcp::socket socket)
|
||||
{
|
||||
if (ec)
|
||||
{
|
||||
Fail(ec, "accept");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::make_shared<HttpSession>(std::move(socket), doc_root_)->Run();
|
||||
}
|
||||
|
||||
DoAccept();
|
||||
}
|
||||
} // namespace uad
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/beast.hpp>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
class Listener : public std::enable_shared_from_this<Listener>
|
||||
{
|
||||
boost::asio::io_context& ioc_;
|
||||
boost::asio::ip::tcp::acceptor acceptor_;
|
||||
std::shared_ptr<std::string const> doc_root_;
|
||||
|
||||
public:
|
||||
Listener(boost::asio::io_context& ioc, boost::asio::ip::tcp::endpoint endpoint,
|
||||
std::shared_ptr<std::string const> const& doc_root);
|
||||
|
||||
void Run();
|
||||
|
||||
private:
|
||||
void DoAccept();
|
||||
|
||||
void OnAccept(boost::beast::error_code ec, boost::asio::ip::tcp::socket socket);
|
||||
};
|
||||
}
|
||||
+32
-21
@@ -1,8 +1,13 @@
|
||||
#include "sdk.h"
|
||||
#ifdef WIN32
|
||||
#include <sdkddkver.h>
|
||||
#endif
|
||||
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <algorithm>
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <mysqlx/xdevapi.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@@ -10,46 +15,52 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "RequestHandlers/BasicRequestHandler.h"
|
||||
#include "Listener.h"
|
||||
#include "./session/WebsocketSession.h"
|
||||
#include "./listener/Listener.h"
|
||||
#include "./db/mysql_connector.h"
|
||||
#include "entities/user.h"
|
||||
|
||||
namespace beast = boost::beast;
|
||||
namespace http = beast::http;
|
||||
namespace websocket = beast::websocket;
|
||||
namespace net = boost::asio;
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
using namespace uad;
|
||||
using namespace std;
|
||||
using namespace std::string_literals;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc != 5)
|
||||
if (argc != 6)
|
||||
{
|
||||
std::cerr <<
|
||||
"Usage: http-server-async <address> <port> <doc_root> <threads>\n" <<
|
||||
"Example:\n" <<
|
||||
" http-server-async 0.0.0.0 8080 . 1\n";
|
||||
std::cerr << "Usage: advanced-server <address> <port> <doc_root> <threads> <mysqlx://user:password@localhost:3306>\n"
|
||||
<< "Example:\n"
|
||||
<< " advanced-server 0.0.0.0 8080 . 1\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
auto const address = net::ip::make_address(argv[1]);
|
||||
auto const port = static_cast<unsigned short>(std::atoi(argv[2]));
|
||||
auto const doc_root = std::make_shared<std::string>(argv[3]);
|
||||
auto const threads = std::max<int>(1, std::atoi(argv[4]));
|
||||
string mysql_credentials = argv[5];
|
||||
|
||||
net::io_context ioc {threads};
|
||||
uad::SetMySqlSession(new mysqlx::Session(mysql_credentials));
|
||||
|
||||
std::make_shared<Listener>(
|
||||
ioc,
|
||||
tcp::endpoint {address, port},
|
||||
doc_root)->Run();
|
||||
net::io_context ioc{threads};
|
||||
|
||||
std::make_shared<Listener>(ioc, tcp::endpoint{address, port}, doc_root)->Run();
|
||||
|
||||
net::signal_set signals(ioc, SIGINT, SIGTERM);
|
||||
signals.async_wait([&](beast::error_code const&, int) { ioc.stop(); });
|
||||
|
||||
std::vector<std::thread> v;
|
||||
v.reserve(threads - 1);
|
||||
for (auto i = threads - 1; i > 0; --i)
|
||||
v.emplace_back(
|
||||
[&ioc]
|
||||
{
|
||||
ioc.run();
|
||||
});
|
||||
v.emplace_back([&ioc] { ioc.run(); });
|
||||
ioc.run();
|
||||
|
||||
for (auto& t : v)
|
||||
t.join();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include "HttpSession.h"
|
||||
#include "WebsocketSession.h"
|
||||
#include "./../endpoints_handlers/HandleRequest.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
HttpSession::Queue::Queue(HttpSession& self) : self_(self)
|
||||
{
|
||||
static_assert(limit > 0, "Queue limit must be positive");
|
||||
items_.reserve(limit);
|
||||
}
|
||||
|
||||
bool HttpSession::Queue::IsFull() const { return items_.size() >= limit; }
|
||||
|
||||
bool HttpSession::Queue::OnWrite()
|
||||
{
|
||||
BOOST_ASSERT(!items_.empty());
|
||||
auto const was_full = IsFull();
|
||||
items_.erase(items_.begin());
|
||||
if (!items_.empty())
|
||||
(*items_.front())();
|
||||
return was_full;
|
||||
}
|
||||
|
||||
HttpSession::HttpSession(boost::asio::ip::tcp::socket&& socket,
|
||||
std::shared_ptr<std::string const> const& doc_root) :
|
||||
stream_(std::move(socket)), doc_root_(doc_root), queue_(*this)
|
||||
{
|
||||
}
|
||||
|
||||
void HttpSession::Run()
|
||||
{
|
||||
boost::asio::dispatch(
|
||||
stream_.get_executor(),
|
||||
boost::beast::bind_front_handler(&HttpSession::DoRead, this->shared_from_this()));
|
||||
}
|
||||
|
||||
void HttpSession::DoRead()
|
||||
{
|
||||
parser_.emplace();
|
||||
|
||||
parser_->body_limit(10000);
|
||||
|
||||
stream_.expires_after(std::chrono::seconds(30));
|
||||
|
||||
boost::beast::http::async_read(
|
||||
stream_, buffer_, *parser_,
|
||||
boost::beast::bind_front_handler(&HttpSession::OnRead, shared_from_this()));
|
||||
}
|
||||
|
||||
void HttpSession::OnRead(boost::beast::error_code ec, std::size_t bytes_transferred)
|
||||
{
|
||||
boost::ignore_unused(bytes_transferred);
|
||||
|
||||
if (ec == boost::beast::http::error::end_of_stream)
|
||||
return DoClose();
|
||||
|
||||
if (ec)
|
||||
return Fail(ec, "read");
|
||||
|
||||
if (boost::beast::websocket::is_upgrade(parser_->get()))
|
||||
{
|
||||
std::make_shared<WebsocketSession>(stream_.release_socket())->DoAccept(parser_->release());
|
||||
return;
|
||||
}
|
||||
|
||||
HandleRequest(*doc_root_, parser_->release(), queue_);
|
||||
|
||||
if (!queue_.IsFull())
|
||||
DoRead();
|
||||
}
|
||||
|
||||
void HttpSession::OnWrite(bool close, boost::beast::error_code ec, std::size_t bytes_transferred)
|
||||
{
|
||||
boost::ignore_unused(bytes_transferred);
|
||||
|
||||
if (ec)
|
||||
return Fail(ec, "write");
|
||||
|
||||
if (close)
|
||||
{
|
||||
return DoClose();
|
||||
}
|
||||
|
||||
if (queue_.OnWrite())
|
||||
{
|
||||
DoRead();
|
||||
}
|
||||
}
|
||||
|
||||
void HttpSession::DoClose()
|
||||
{
|
||||
boost::beast::error_code ec;
|
||||
stream_.socket().shutdown(boost::asio::ip::tcp::socket::shutdown_send, ec);
|
||||
}
|
||||
} // namespace uad
|
||||
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <boost/beast.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
class HttpSession : public std::enable_shared_from_this<HttpSession>
|
||||
{
|
||||
class Queue
|
||||
{
|
||||
enum
|
||||
{
|
||||
limit = 8
|
||||
};
|
||||
|
||||
struct work
|
||||
{
|
||||
virtual void operator()() = 0;
|
||||
virtual ~work() = default;
|
||||
};
|
||||
|
||||
HttpSession& self_;
|
||||
std::vector<std::unique_ptr<work>> items_;
|
||||
|
||||
public:
|
||||
explicit Queue(HttpSession& self);
|
||||
|
||||
bool IsFull() const;
|
||||
|
||||
bool OnWrite();
|
||||
|
||||
template <bool isRequest, class Body, class Fields>
|
||||
void operator()(boost::beast::http::message<isRequest, Body, Fields>&& msg)
|
||||
{
|
||||
struct work_impl : work
|
||||
{
|
||||
HttpSession& self_;
|
||||
boost::beast::http::message<isRequest, Body, Fields> msg_;
|
||||
|
||||
work_impl(HttpSession& self, boost::beast::http::message<isRequest, Body, Fields>&& msg) :
|
||||
self_(self), msg_(std::move(msg))
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
boost::beast::http::async_write(self_.stream_, msg_,
|
||||
boost::beast::bind_front_handler(&HttpSession::OnWrite,
|
||||
self_.shared_from_this(), msg_.need_eof()));
|
||||
}
|
||||
};
|
||||
|
||||
items_.push_back(boost::make_unique<work_impl>(self_, std::move(msg)));
|
||||
|
||||
if (items_.size() == 1)
|
||||
(*items_.front())();
|
||||
}
|
||||
};
|
||||
|
||||
boost::beast::tcp_stream stream_;
|
||||
boost::beast::flat_buffer buffer_;
|
||||
std::shared_ptr<std::string const> doc_root_;
|
||||
Queue queue_;
|
||||
boost::optional<boost::beast::http::request_parser<boost::beast::http::string_body>> parser_;
|
||||
|
||||
public:
|
||||
HttpSession(boost::asio::ip::tcp::socket&& socket, std::shared_ptr<std::string const> const& doc_root);
|
||||
|
||||
void Run();
|
||||
|
||||
private:
|
||||
void DoRead();
|
||||
|
||||
void OnRead(boost::beast::error_code ec, std::size_t bytes_transferred);
|
||||
|
||||
void OnWrite(bool close, boost::beast::error_code ec, std::size_t bytes_transferred);
|
||||
|
||||
void DoClose();
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "WebsocketSession.h"
|
||||
|
||||
#include "./../helpers/helpers.h"
|
||||
|
||||
namespace uad
|
||||
{
|
||||
WebsocketSession::WebsocketSession(boost::asio::ip::tcp::socket&& socket) : ws_(std::move(socket))
|
||||
{
|
||||
}
|
||||
|
||||
void WebsocketSession::OnAccept(boost::beast::error_code ec)
|
||||
{
|
||||
if (ec)
|
||||
return Fail(ec, "accept");
|
||||
|
||||
DoRead();
|
||||
}
|
||||
|
||||
void WebsocketSession::DoRead()
|
||||
{
|
||||
ws_.async_read(buffer_,
|
||||
boost::beast::bind_front_handler(&WebsocketSession::OnRead, shared_from_this()));
|
||||
}
|
||||
|
||||
void WebsocketSession::OnRead(boost::beast::error_code ec, std::size_t bytes_transferred)
|
||||
{
|
||||
boost::ignore_unused(bytes_transferred);
|
||||
|
||||
if (ec == boost::beast::websocket::error::closed)
|
||||
return;
|
||||
|
||||
if (ec)
|
||||
Fail(ec, "read");
|
||||
|
||||
ws_.text(ws_.got_text());
|
||||
ws_.async_write(buffer_.data(),
|
||||
boost::beast::bind_front_handler(&WebsocketSession::OnWrite, shared_from_this()));
|
||||
}
|
||||
|
||||
void WebsocketSession::OnWrite(boost::beast::error_code ec, std::size_t bytes_transferred)
|
||||
{
|
||||
boost::ignore_unused(bytes_transferred);
|
||||
|
||||
if (ec)
|
||||
return Fail(ec, "write");
|
||||
|
||||
buffer_.consume(buffer_.size());
|
||||
|
||||
DoRead();
|
||||
}
|
||||
} // namespace uad
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <boost/beast.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace uad
|
||||
{
|
||||
class WebsocketSession : public std::enable_shared_from_this<WebsocketSession>
|
||||
{
|
||||
boost::beast::websocket::stream<boost::beast::tcp_stream> ws_;
|
||||
boost::beast::flat_buffer buffer_;
|
||||
|
||||
public:
|
||||
explicit WebsocketSession(boost::asio::ip::tcp::socket&& socket);
|
||||
|
||||
template <class Body, class Allocator>
|
||||
void DoAccept(boost::beast::http::request<Body, boost::beast::http::basic_fields<Allocator>> req)
|
||||
{
|
||||
ws_.set_option(boost::beast::websocket::stream_base::timeout::suggested(boost::beast::role_type::server));
|
||||
|
||||
ws_.set_option(boost::beast::websocket::stream_base::decorator(
|
||||
[](boost::beast::websocket::response_type& res)
|
||||
{
|
||||
res.set(boost::beast::http::field::server, std::string(BOOST_BEAST_VERSION_STRING) + " advanced-server");
|
||||
}));
|
||||
|
||||
ws_.async_accept(req,
|
||||
boost::beast::bind_front_handler(&WebsocketSession::OnAccept, shared_from_this()));
|
||||
}
|
||||
|
||||
private:
|
||||
void OnAccept(boost::beast::error_code ec);
|
||||
|
||||
void DoRead();
|
||||
|
||||
void OnRead(boost::beast::error_code ec, std::size_t bytes_transferred);
|
||||
|
||||
void OnWrite(boost::beast::error_code ec, std::size_t bytes_transferred);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
#ifdef WIN32
|
||||
#include <sdkddkver.h>
|
||||
#endif
|
||||
|
||||
#define BOOST_TEST_MODULE Controllers
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include "./../../src/endpoints_handlers/Controller.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
using namespace uad;
|
||||
|
||||
using IControllerMock = Controller<beast::http::string_body,
|
||||
std::allocator<char>,
|
||||
beast::http::string_body>;
|
||||
|
||||
class MockExecutor : public IExecutor<beast::http::string_body,
|
||||
std::allocator<char>,
|
||||
beast::http::string_body>
|
||||
{
|
||||
public:
|
||||
beast::http::response<beast::http::string_body> operator ()(
|
||||
beast::http::request<beast::http::string_body, beast::http::basic_fields<std::allocator<char>>>&& req
|
||||
) override
|
||||
{
|
||||
boost::beast::http::response<boost::beast::http::string_body> res{
|
||||
boost::beast::http::status::not_found, req.version()};
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Should_Be_Initiated_With_No_Executors)
|
||||
{
|
||||
IControllerMock my_controller;
|
||||
|
||||
BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::get).has_value());
|
||||
BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::post).has_value());
|
||||
BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::put).has_value());
|
||||
BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::delete_).has_value());
|
||||
BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::head).has_value());
|
||||
BOOST_CHECK(!my_controller.FindExecutor(beast::http::verb::options).has_value());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Should_Be_Initiated_With_Unordered_Map_HTTP_Methods_To_Executors)
|
||||
{
|
||||
IControllerMock::HTTPMethodsToExecutors executors;
|
||||
|
||||
executors[beast::http::verb::get] = make_shared<MockExecutor>();
|
||||
executors[beast::http::verb::post] = make_shared<MockExecutor>();
|
||||
executors[beast::http::verb::put] = make_shared<MockExecutor>();
|
||||
executors[beast::http::verb::delete_] = make_shared<MockExecutor>();
|
||||
executors[beast::http::verb::head] = make_shared<MockExecutor>();
|
||||
executors[beast::http::verb::options] = make_shared<MockExecutor>();
|
||||
|
||||
IControllerMock my_controller(std::move(executors));
|
||||
|
||||
BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::get).has_value());
|
||||
BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::post).has_value());
|
||||
BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::put).has_value());
|
||||
BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::delete_).has_value());
|
||||
BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::head).has_value());
|
||||
BOOST_CHECK(my_controller.FindExecutor(beast::http::verb::options).has_value());
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifdef WIN32
|
||||
#include <sdkddkver.h>
|
||||
#endif
|
||||
|
||||
#define BOOST_TEST_MODULE Helpers
|
||||
|
||||
#include "./../../src/helpers/helpers.h"
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
using namespace uad;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ToHex_should_cast_single_byte_to_hex_string)
|
||||
{
|
||||
byte a1 = byte(0);
|
||||
byte a2 = byte(1);
|
||||
byte a3 = byte(2);
|
||||
byte a4 = byte(3);
|
||||
byte a5 = byte(4);
|
||||
byte a6 = byte(5);
|
||||
byte a7 = byte(6);
|
||||
byte a8 = byte(15);
|
||||
byte a9 = byte(64);
|
||||
byte a10 = byte(97);
|
||||
byte a11 = byte(127);
|
||||
byte a12 = byte(255);
|
||||
|
||||
BOOST_CHECK_EQUAL(ToHex(&a1, 1), "00"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a2, 1), "01"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a3, 1), "02"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a4, 1), "03"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a5, 1), "04"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a6, 1), "05"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a7, 1), "06"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a8, 1), "0F"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a9, 1), "40"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a10, 1), "61"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a11, 1), "7F"s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a12, 1), "FF"s);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ToHex_should_return_empty_string_if_no_arr_or_no_length)
|
||||
{
|
||||
byte a1 = byte(0);
|
||||
|
||||
BOOST_CHECK_EQUAL(ToHex(nullptr, 0), ""s);
|
||||
BOOST_CHECK_EQUAL(ToHex(&a1, 0), ""s);
|
||||
BOOST_CHECK_EQUAL(ToHex(nullptr, 1), ""s);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Random_should_return_different_numbers_on_multiple_calls)
|
||||
{
|
||||
auto a1 = Random();
|
||||
auto a2 = Random();
|
||||
auto a3 = Random();
|
||||
auto a4 = Random();
|
||||
auto a5 = Random();
|
||||
auto a6 = Random();
|
||||
auto a7 = Random();
|
||||
auto a8 = Random();
|
||||
auto a9 = Random();
|
||||
auto a10 = Random();
|
||||
|
||||
auto b1 = Random();
|
||||
auto b2 = Random();
|
||||
auto b3 = Random();
|
||||
auto b4 = Random();
|
||||
auto b5 = Random();
|
||||
auto b6 = Random();
|
||||
auto b7 = Random();
|
||||
auto b8 = Random();
|
||||
auto b9 = Random();
|
||||
auto b10 = Random();
|
||||
|
||||
BOOST_CHECK(a1 != b1);
|
||||
BOOST_CHECK(a2 != b2);
|
||||
BOOST_CHECK(a3 != b3);
|
||||
BOOST_CHECK(a4 != b4);
|
||||
BOOST_CHECK(a5 != b5);
|
||||
BOOST_CHECK(a6 != b6);
|
||||
BOOST_CHECK(a7 != b7);
|
||||
BOOST_CHECK(a8 != b8);
|
||||
BOOST_CHECK(a9 != b9);
|
||||
BOOST_CHECK(a10 != b10);
|
||||
}
|
||||
Reference in New Issue
Block a user