From 3915a6a0996fef80d09231638dff83128a2d3dd7 Mon Sep 17 00:00:00 2001 From: Zerg1996 Date: Fri, 13 May 2022 20:19:05 +0200 Subject: [PATCH 01/23] Initial implementation actor containers commit --- .clang-format | 94 +++ .gitignore | 632 ++++++++++++++++++ .gitmodules | 3 + CMakeLists.txt | 110 +++ LICENSE_1_0.txt | 21 + README.md | 23 + cmake/CheckAVX.cmake | 63 ++ cmake/CheckSSE.cmake | 138 ++++ cmake/PlatformConfiguration.cmake | 141 ++++ cmake/TargetArchitecture.cmake | 163 +++++ cmake/TargetConfiguration.cmake | 6 + cmake/architectures/alpha.json | 8 + cmake/architectures/arm32.json | 16 + cmake/architectures/arm64.json | 19 + cmake/architectures/hppa.json | 12 + cmake/architectures/ia64.json | 7 + cmake/architectures/llvm.json | 4 + cmake/architectures/m68k.json | 8 + cmake/architectures/mips32.json | 10 + cmake/architectures/mips64.json | 7 + cmake/architectures/powerpcspe.json | 5 + cmake/architectures/ppc32.json | 12 + cmake/architectures/ppc64.json | 15 + cmake/architectures/riscv64.json | 5 + cmake/architectures/s390.json | 4 + cmake/architectures/s390x.json | 4 + cmake/architectures/sparc32.json | 8 + cmake/architectures/sparc64.json | 5 + cmake/architectures/superh.json | 7 + cmake/architectures/x32.json | 17 + cmake/architectures/x86_32.json | 30 + cmake/architectures/x86_64.json | 24 + cmake/modules/.gitattributes | 3 + cmake/modules/.travis.yml | 50 ++ cmake/modules/CMakeLists.txt | 7 + cmake/modules/README.md | 29 + cmake/modules/appveyor.yml | 38 ++ cmake/modules/doc/conf.py | 333 +++++++++ cmake/modules/doc/index.rst | 14 + cmake/modules/doc/make.bat | 281 ++++++++ cmake/modules/doc/requirements.txt | 2 + cmake/modules/doc/src/Building.rst | 319 +++++++++ cmake/modules/doc/src/CMDeploy.rst | 28 + cmake/modules/doc/src/CMExport.rst | 31 + cmake/modules/doc/src/CMIgnorePackage.rst | 15 + cmake/modules/doc/src/CMInstallTargets.rst | 25 + cmake/modules/doc/src/CMPkgConfig.rst | 59 ++ cmake/modules/doc/src/CMProperties.rst | 65 ++ cmake/modules/doc/src/CMSetupVersion.rst | 33 + cmake/modules/doc/src/CMTest.rst | 89 +++ cmake/modules/doc/src/Intro.rst | 89 +++ cmake/modules/doc/src/Modules.rst | 15 + .../share/modules/cmake/CMConfig.cmake | 144 ++++ .../share/modules/cmake/CMDeploy.cmake | 48 ++ .../share/modules/cmake/CMExport.cmake | 147 ++++ .../share/modules/cmake/CMFuture.cmake | 87 +++ .../share/modules/cmake/CMIgnorePackage.cmake | 6 + .../modules/cmake/CMInstallTargets.cmake | 43 ++ .../share/modules/cmake/CMPkgConfig.cmake | 250 +++++++ .../share/modules/cmake/CMProperties.cmake | 98 +++ .../share/modules/cmake/CMSetupVersion.cmake | 52 ++ .../modules/share/modules/cmake/CMTest.cmake | 232 +++++++ .../share/modules/cmake/CMToSnakeCase.cmake | 11 + cmake/modules/share/modules/cmake/version.hpp | 10 + cmake/modules/test/CMakeLists.txt | 43 ++ cmake/modules/test/basicapp/CMakeLists.txt | 21 + cmake/modules/test/basicapp/main.cpp | 6 + cmake/modules/test/checkprop/CMakeLists.txt | 12 + cmake/modules/test/fail/simple-test.cmake | 1 + .../test/findpackagecheck/CMakeLists.txt | 15 + .../modules/test/findpackagecheck/main.cpp.in | 4 + cmake/modules/test/libbasic/CMakeLists.txt | 21 + cmake/modules/test/libbasic/main.cpp | 6 + cmake/modules/test/libbasic/test.cpp | 2 + .../test/libbasicnamespace/CMakeLists.txt | 21 + cmake/modules/test/libbasicnamespace/main.cpp | 5 + cmake/modules/test/libbasicnamespace/test.cpp | 2 + cmake/modules/test/libsimple/CMakeLists.txt | 51 ++ cmake/modules/test/libsimple/compiletest.cpp | 7 + .../test/libsimple/compiletestwillfail.cpp | 6 + cmake/modules/test/libsimple/include/simple.h | 22 + cmake/modules/test/libsimple/test.cpp | 5 + cmake/modules/test/libsimple/testwillfail.cpp | 6 + .../test/libsimplecustomname/CMakeLists.txt | 29 + .../test/libsimplecustomname/compiletest.cpp | 7 + .../test/libsimplecustomname/include/simple.h | 8 + .../modules/test/libsimplecustomname/test.cpp | 5 + .../test/libsimplenamespace/CMakeLists.txt | 28 + .../test/libsimplenamespace/compiletest.cpp | 7 + .../test/libsimplenamespace/include/simple.h | 12 + .../modules/test/libsimplenamespace/test.cpp | 5 + .../modules/test/parseversion/CMakeLists.txt | 32 + .../modules/test/parseversion/compiletest.cpp | 7 + .../test/parseversion/include/simple.h | 10 + .../test/parseversion/include/version.h | 8 + cmake/modules/test/parseversion/test.cpp | 5 + cmake/modules/test/pass/basic.cmake | 6 + .../modules/test/pass/defaultproperties.cmake | 15 + cmake/modules/test/pass/parseversion.cmake | 1 + cmake/modules/test/pass/properties.cmake | 1 + cmake/modules/test/pass/simple-shared.cmake | 4 + .../modules/test/pass/simple-test-build.cmake | 3 + .../test/pass/simple-test-shared.cmake | 3 + cmake/modules/test/pass/simple-test.cmake | 3 + cmake/modules/test/pass/simple.cmake | 4 + .../modules/test/pass/simplecustomname.cmake | 2 + cmake/modules/test/pass/simplenamespace.cmake | 2 + cmake/modules/test/pass/superproject.cmake | 5 + .../test/pkgconfigcheck/CMakeLists.txt | 46 ++ cmake/modules/test/properties/CMakeLists.txt | 67 ++ .../modules/test/properties/include/simple.h | 8 + cmake/modules/test/properties/nowarnings.cpp | 5 + cmake/modules/test/properties/rtti.cpp | 20 + cmake/modules/test/properties/test.cpp | 5 + cmake/modules/test/properties/throw.cpp | 6 + cmake/modules/test/properties/warnings.cpp | 9 + cmake/modules/test/simpletest/CMakeLists.txt | 26 + .../modules/test/simpletest/include/simple.h | 1 + cmake/modules/test/simpletest/simple.cpp | 4 + cmake/modules/test/simpletest/test.cpp | 5 + .../test/simpletest/test/CMakeLists.txt | 7 + cmake/modules/test/simpletest/test/test.cpp | 5 + .../modules/test/superproject/CMakeLists.txt | 10 + cmake/modules/test/test.cmake | 124 ++++ cmake/packages/FindCrypto3.cmake | 0 cmake/packages/FindValgrind.cmake | 23 + example/CMakeLists.txt | 56 ++ example/merkle/merkle.cpp | 100 +++ .../crypto3/container_actor/merkle/tree.hpp | 123 ++++ test/CMakeLists.txt | 160 +++++ test/merkle/merkle.cpp | 43 ++ 131 files changed, 5595 insertions(+) create mode 100644 .clang-format create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 100644 LICENSE_1_0.txt create mode 100644 README.md create mode 100644 cmake/CheckAVX.cmake create mode 100644 cmake/CheckSSE.cmake create mode 100644 cmake/PlatformConfiguration.cmake create mode 100644 cmake/TargetArchitecture.cmake create mode 100644 cmake/TargetConfiguration.cmake create mode 100644 cmake/architectures/alpha.json create mode 100644 cmake/architectures/arm32.json create mode 100644 cmake/architectures/arm64.json create mode 100644 cmake/architectures/hppa.json create mode 100644 cmake/architectures/ia64.json create mode 100644 cmake/architectures/llvm.json create mode 100644 cmake/architectures/m68k.json create mode 100644 cmake/architectures/mips32.json create mode 100644 cmake/architectures/mips64.json create mode 100644 cmake/architectures/powerpcspe.json create mode 100644 cmake/architectures/ppc32.json create mode 100644 cmake/architectures/ppc64.json create mode 100644 cmake/architectures/riscv64.json create mode 100644 cmake/architectures/s390.json create mode 100644 cmake/architectures/s390x.json create mode 100644 cmake/architectures/sparc32.json create mode 100644 cmake/architectures/sparc64.json create mode 100644 cmake/architectures/superh.json create mode 100644 cmake/architectures/x32.json create mode 100644 cmake/architectures/x86_32.json create mode 100644 cmake/architectures/x86_64.json create mode 100644 cmake/modules/.gitattributes create mode 100644 cmake/modules/.travis.yml create mode 100644 cmake/modules/CMakeLists.txt create mode 100644 cmake/modules/README.md create mode 100644 cmake/modules/appveyor.yml create mode 100644 cmake/modules/doc/conf.py create mode 100644 cmake/modules/doc/index.rst create mode 100644 cmake/modules/doc/make.bat create mode 100644 cmake/modules/doc/requirements.txt create mode 100644 cmake/modules/doc/src/Building.rst create mode 100644 cmake/modules/doc/src/CMDeploy.rst create mode 100644 cmake/modules/doc/src/CMExport.rst create mode 100644 cmake/modules/doc/src/CMIgnorePackage.rst create mode 100644 cmake/modules/doc/src/CMInstallTargets.rst create mode 100644 cmake/modules/doc/src/CMPkgConfig.rst create mode 100644 cmake/modules/doc/src/CMProperties.rst create mode 100644 cmake/modules/doc/src/CMSetupVersion.rst create mode 100644 cmake/modules/doc/src/CMTest.rst create mode 100644 cmake/modules/doc/src/Intro.rst create mode 100644 cmake/modules/doc/src/Modules.rst create mode 100644 cmake/modules/share/modules/cmake/CMConfig.cmake create mode 100644 cmake/modules/share/modules/cmake/CMDeploy.cmake create mode 100644 cmake/modules/share/modules/cmake/CMExport.cmake create mode 100644 cmake/modules/share/modules/cmake/CMFuture.cmake create mode 100644 cmake/modules/share/modules/cmake/CMIgnorePackage.cmake create mode 100644 cmake/modules/share/modules/cmake/CMInstallTargets.cmake create mode 100644 cmake/modules/share/modules/cmake/CMPkgConfig.cmake create mode 100644 cmake/modules/share/modules/cmake/CMProperties.cmake create mode 100644 cmake/modules/share/modules/cmake/CMSetupVersion.cmake create mode 100644 cmake/modules/share/modules/cmake/CMTest.cmake create mode 100644 cmake/modules/share/modules/cmake/CMToSnakeCase.cmake create mode 100644 cmake/modules/share/modules/cmake/version.hpp create mode 100644 cmake/modules/test/CMakeLists.txt create mode 100644 cmake/modules/test/basicapp/CMakeLists.txt create mode 100644 cmake/modules/test/basicapp/main.cpp create mode 100644 cmake/modules/test/checkprop/CMakeLists.txt create mode 100644 cmake/modules/test/fail/simple-test.cmake create mode 100644 cmake/modules/test/findpackagecheck/CMakeLists.txt create mode 100644 cmake/modules/test/findpackagecheck/main.cpp.in create mode 100644 cmake/modules/test/libbasic/CMakeLists.txt create mode 100644 cmake/modules/test/libbasic/main.cpp create mode 100644 cmake/modules/test/libbasic/test.cpp create mode 100644 cmake/modules/test/libbasicnamespace/CMakeLists.txt create mode 100644 cmake/modules/test/libbasicnamespace/main.cpp create mode 100644 cmake/modules/test/libbasicnamespace/test.cpp create mode 100644 cmake/modules/test/libsimple/CMakeLists.txt create mode 100644 cmake/modules/test/libsimple/compiletest.cpp create mode 100644 cmake/modules/test/libsimple/compiletestwillfail.cpp create mode 100644 cmake/modules/test/libsimple/include/simple.h create mode 100644 cmake/modules/test/libsimple/test.cpp create mode 100644 cmake/modules/test/libsimple/testwillfail.cpp create mode 100644 cmake/modules/test/libsimplecustomname/CMakeLists.txt create mode 100644 cmake/modules/test/libsimplecustomname/compiletest.cpp create mode 100644 cmake/modules/test/libsimplecustomname/include/simple.h create mode 100644 cmake/modules/test/libsimplecustomname/test.cpp create mode 100644 cmake/modules/test/libsimplenamespace/CMakeLists.txt create mode 100644 cmake/modules/test/libsimplenamespace/compiletest.cpp create mode 100644 cmake/modules/test/libsimplenamespace/include/simple.h create mode 100644 cmake/modules/test/libsimplenamespace/test.cpp create mode 100644 cmake/modules/test/parseversion/CMakeLists.txt create mode 100644 cmake/modules/test/parseversion/compiletest.cpp create mode 100644 cmake/modules/test/parseversion/include/simple.h create mode 100644 cmake/modules/test/parseversion/include/version.h create mode 100644 cmake/modules/test/parseversion/test.cpp create mode 100644 cmake/modules/test/pass/basic.cmake create mode 100644 cmake/modules/test/pass/defaultproperties.cmake create mode 100644 cmake/modules/test/pass/parseversion.cmake create mode 100644 cmake/modules/test/pass/properties.cmake create mode 100644 cmake/modules/test/pass/simple-shared.cmake create mode 100644 cmake/modules/test/pass/simple-test-build.cmake create mode 100644 cmake/modules/test/pass/simple-test-shared.cmake create mode 100644 cmake/modules/test/pass/simple-test.cmake create mode 100644 cmake/modules/test/pass/simple.cmake create mode 100644 cmake/modules/test/pass/simplecustomname.cmake create mode 100644 cmake/modules/test/pass/simplenamespace.cmake create mode 100644 cmake/modules/test/pass/superproject.cmake create mode 100644 cmake/modules/test/pkgconfigcheck/CMakeLists.txt create mode 100644 cmake/modules/test/properties/CMakeLists.txt create mode 100644 cmake/modules/test/properties/include/simple.h create mode 100644 cmake/modules/test/properties/nowarnings.cpp create mode 100644 cmake/modules/test/properties/rtti.cpp create mode 100644 cmake/modules/test/properties/test.cpp create mode 100644 cmake/modules/test/properties/throw.cpp create mode 100644 cmake/modules/test/properties/warnings.cpp create mode 100644 cmake/modules/test/simpletest/CMakeLists.txt create mode 100644 cmake/modules/test/simpletest/include/simple.h create mode 100644 cmake/modules/test/simpletest/simple.cpp create mode 100644 cmake/modules/test/simpletest/test.cpp create mode 100644 cmake/modules/test/simpletest/test/CMakeLists.txt create mode 100644 cmake/modules/test/simpletest/test/test.cpp create mode 100644 cmake/modules/test/superproject/CMakeLists.txt create mode 100644 cmake/modules/test/test.cmake create mode 100644 cmake/packages/FindCrypto3.cmake create mode 100644 cmake/packages/FindValgrind.cmake create mode 100644 example/CMakeLists.txt create mode 100644 example/merkle/merkle.cpp create mode 100644 include/nil/crypto3/container_actor/merkle/tree.hpp create mode 100644 test/CMakeLists.txt create mode 100644 test/merkle/merkle.cpp diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..3efc3f0e7f --- /dev/null +++ b/.clang-format @@ -0,0 +1,94 @@ +--- +BasedOnStyle: WebKit +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BreakAfterJavaFieldAnnotations: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: AfterColon +BreakStringLiterals: true +ColumnLimit: 120 +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: true +FixNamespaceComments: true +ForEachMacros: ['BOOST_FOREACH'] +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^"(<)/' + Priority: 1 + - Regex: '^(<(boost)/)' + Priority: 2 + - Regex: '^(<(nil\/crypto3)/)' + Priority: 3 + - Regex: '.*' + Priority: 4 +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: true +KeepEmptyLinesAtTheStartOfBlocks: true +Language: Cpp +NamespaceIndentation: All +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PointerAlignment: Right +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 4 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: true +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: c++11 +TabWidth: 4 +UseTab: Never + +... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..26d47ea724 --- /dev/null +++ b/.gitignore @@ -0,0 +1,632 @@ +## Core latex/pdflatex auxiliary files: +*.aux +*.lof +*.log +*.lot +*.fls +*.out +*.toc +*.fmt +*.fot +*.cb +*.cb2 +.*.lb + +## Intermediate documents: +*.dvi +*.xdv +*-converted-to.* +# these rules might exclude image files for figures etc. +# *.ps +# *.eps +# *.pdf + +## Generated if empty string is given at "Please type another file name for output:" +.pdf + +## Bibliography auxiliary files (bibtex/biblatex/biber): +*.bbl +*.bcf +*.blg +*-blx.aux +*-blx.bib +*.run.xml + +## Build tool auxiliary files: +*.fdb_latexmk +*.synctex +*.synctex(busy) +*.synctex.gz +*.synctex.gz(busy) +*.pdfsync + +## Auxiliary and intermediate files from other packages: +# algorithms +*.alg +*.loa + +# achemso +acs-*.bib + +# amsthm +*.thm + +# beamer +*.nav +*.pre +*.snm +*.vrb + +# changes +*.soc + +# cprotect +*.cpt + +# elsarticle (documentclass of Elsevier journals) +*.spl + +# endnotes +*.ent + +# fixme +*.lox + +# feynmf/feynmp +*.mf +*.mp +*.t[1-9] +*.t[1-9][0-9] +*.tfm + +#(r)(e)ledmac/(r)(e)ledpar +*.end +*.?end +*.[1-9] +*.[1-9][0-9] +*.[1-9][0-9][0-9] +*.[1-9]R +*.[1-9][0-9]R +*.[1-9][0-9][0-9]R +*.eledsec[1-9] +*.eledsec[1-9]R +*.eledsec[1-9][0-9] +*.eledsec[1-9][0-9]R +*.eledsec[1-9][0-9][0-9] +*.eledsec[1-9][0-9][0-9]R + +# glossaries +*.acn +*.acr +*.glg +*.glo +*.gls +*.glsdefs + +# gnuplottex +*-gnuplottex-* + +# gregoriotex +*.gaux +*.gtex + +# htlatex +*.4ct +*.4tc +*.idv +*.lg +*.trc +*.xref + +# hyperref +*.brf + +# knitr +*-concordance.tex +# TODO Comment the next line if you want to keep your tikz graphics files +*.tikz +*-tikzDictionary + +# listings +*.lol + +# makeidx +*.idx +*.ilg +*.ind +*.ist + +# minitoc +*.maf +*.mlf +*.mlt +*.mtc[0-9]* +*.slf[0-9]* +*.slt[0-9]* +*.stc[0-9]* + +# minted +_minted* +*.pyg + +# morewrites +*.mw + +# nomencl +*.nlg +*.nlo +*.nls + +# pax +*.pax + +# pdfpcnotes +*.pdfpc + +# sagetex +*.sagetex.sage +*.sagetex.py +*.sagetex.scmd + +# scrwfile +*.wrt + +# sympy +*.sout +*.sympy +sympy-plots-for-*.tex/ + +# pdfcomment +*.upa +*.upb + +# pythontex +*.pytxcode +pythontex-files-*/ + +# thmtools +*.loe + +# TikZ & PGF +*.dpth +*.md5 +*.auxlock + +# todonotes +*.tdo + +# easy-todo +*.lod + +# xmpincl +*.xmpi + +# xindy +*.xdy + +# xypic precompiled matrices +*.xyc + +# endfloat +*.ttt +*.fff + +# Latexian +TSWLatexianTemp* + +## Editors: +# WinEdt +*.bak +*.sav + +# Texpad +.texpadtmp + +# Kile +*.backup + +# KBibTeX +*~[0-9]* + +# auto folder when using emacs and auctex +./auto/* +*.el + +# expex forward references with \gathertags +*-tags.tex + +# standalone packages +*.sta + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +### CLion+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Ruby plugin and RubyMine +/.rakeTasks + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### CLion+all Patch ### +# Ignores the whole .idea folder and all .iml files +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +### CMake ### +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +build + +### LaTeX ### +## Core latex/pdflatex auxiliary files: +*.aux +*.lof +*.log +*.lot +*.fls +*.toc +*.fmt +*.fot +*.cb +*.cb2 + +## Intermediate documents: +*.dvi +*.xdv +*-converted-to.* +# these rules might exclude image files for figures etc. +# *.ps +# *.eps +# *.pdf + +## Generated if empty string is given at "Please type another file name for output:" +.pdf + +## Bibliography auxiliary files (bibtex/biblatex/biber): +*.bbl +*.bcf +*.blg +*-blx.aux +*-blx.bib +*.run.xml + +## Build tool auxiliary files: +*.fdb_latexmk +*.synctex +*.synctex(busy) +*.synctex.gz +*.synctex.gz(busy) +*.pdfsync +*Notes.bib + +## Auxiliary and intermediate files from other packages: +# algorithms +*.alg +*.loa + +# achemso +acs-*.bib + +# amsthm +*.thm + +# beamer +*.nav +*.pre +*.snm +*.vrb + +# changes +*.soc + +# cprotect +*.cpt + +# elsarticle (documentclass of Elsevier journals) +*.spl + +# endnotes +*.ent + +# fixme +*.lox + +# feynmf/feynmp +*.mf +*.mp +*.t[1-9] +*.t[1-9][0-9] +*.tfm + +#(r)(e)ledmac/(r)(e)ledpar +*.end +*.?end +*.[1-9] +*.[1-9][0-9] +*.[1-9][0-9][0-9] +*.[1-9]R +*.[1-9][0-9]R +*.[1-9][0-9][0-9]R +*.eledsec[1-9] +*.eledsec[1-9]R +*.eledsec[1-9][0-9] +*.eledsec[1-9][0-9]R +*.eledsec[1-9][0-9][0-9] +*.eledsec[1-9][0-9][0-9]R + +# glossaries +*.acn +*.acr +*.glg +*.glo +*.gls +*.glsdefs + +# gnuplottex +*-gnuplottex-* + +# gregoriotex +*.gaux +*.gtex + +# hyperref +*.brf + +# knitr +*-concordance.tex +# TODO Comment the next line if you want to keep your tikz graphics files +*.tikz +*-tikzDictionary + +# listings +*.lol + +# makeidx +*.idx +*.ilg +*.ind +*.ist + +# minitoc +*.maf +*.mlf +*.mlt +*.mtc[0-9]* +*.slf[0-9]* +*.slt[0-9]* +*.stc[0-9]* + +# minted +_minted* +*.pyg + +# morewrites +*.mw + +# nomencl +*.nlo + +# pax +*.pax + +# pdfpcnotes +*.pdfpc + +# sagetex +*.sagetex.sage +*.sagetex.py +*.sagetex.scmd + +# scrwfile +*.wrt + +# sympy +*.sout +*.sympy +sympy-plots-for-*.tex/ + +# pdfcomment +*.upa +*.upb + +# pythontex +*.pytxcode +pythontex-files-*/ + +# thmtools +*.loe + +# TikZ & PGF +*.dpth +*.md5 +*.auxlock + +# todonotes +*.tdo + +# easy-todo +*.lod + +# xindy +*.xdy + +# xypic precompiled matrices +*.xyc + +# endfloat +*.ttt +*.fff + +# Latexian +TSWLatexianTemp* + +## Editors: +# WinEdt +*.bak +*.sav + +# Texpad +.texpadtmp + +# Kile +*.backup + +# KBibTeX +*~[0-9]* + +# auto folder when using emacs and auctex +/auto/* + +# expex forward references with \gathertags +*-tags.tex + +### LaTeX Patch ### +# glossaries +*.glstex + + +# Text file backups (e.g. gedit, joe) +*~ +\#*\# +.\#* + +# Archive files +*.tgz +*.tar + +# Logs +*.log + +# Patch files +*.patch +*.diff +*.orig +*.rej + +# Cache and temporary files +*.pyc +.DS_Store +*.swp + +# ctags/etags files +/TAGS +/tags + +# Coverage output +coverage.info +coverage.info.raw +coverage/ +lcov-out/ + +/fuzzer_corpus + +# Profiler outputs +cachegrind.* +callgrind.* + +# Ignore stuff in the top level dir that shouldn't be checked in +/*.c +/*.cpp +/*.h +/*.py +/*.key +/*.pem +/*.der +/*.ber +/*.gpg +/*.pub +/*.crt \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..0267228a00 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "cmake/modules"] + path = cmake/modules + url = git@github.com:BoostCMake/cmake_modules.git \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..584e304652 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,110 @@ +#---------------------------------------------------------------------------// +# MIT License +# +# Copyright (c) 2020 Mikhail Komarov +# Copyright (c) 2021 Aleksei Moskvin +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +#---------------------------------------------------------------------------// + +cmake_minimum_required(VERSION 2.8.12) + +cmake_policy(SET CMP0042 NEW) +cmake_policy(SET CMP0028 NEW) +cmake_policy(SET CMP0048 NEW) +cmake_policy(SET CMP0057 NEW) +cmake_policy(SET CMP0079 OLD) + +list(APPEND CMAKE_MODULE_PATH "cmake" + "cmake/modules/share/modules/cmake") + +cm_find_package(CM) +include(CMConfig) +include(CMSetupVersion) + +cm_workspace(actor) + +macro(cm_find_package NAME) + if (NOT "${NAME}" MATCHES "^${CMAKE_WORKSPACE_NAME}_.*$" AND NOT "${NAME}" STREQUAL CM) + find_package(${ARGV}) + else () + set(${ARGV0}_FOUND ON CACHE BOOL "") + endif () +endmacro() + +cm_find_package(CM) +include(CMDeploy) +include(CMSetupVersion) + +if (NOT Boost_FOUND AND NOT CMAKE_CROSSCOMPILING) + cm_find_package(Boost REQUIRED COMPONENTS filesystem) +endif () + +cm_project(containers WORKSPACE_NAME ${CMAKE_WORKSPACE_NAME} LANGUAGES ASM C CXX) + +option(BUILD_DOXYGEN_DOCS "Build with configuring Doxygen documentation compiler" TRUE) + +set(DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_LIST_DIR}/docs" CACHE STRING "Specify doxygen output directory") + +list(APPEND ${CURRENT_PROJECT_NAME}_PUBLIC_HEADERS + ) + +list(APPEND ${CURRENT_PROJECT_NAME}_UNGROUPED_SOURCES) + +list(APPEND ${CURRENT_PROJECT_NAME}_HEADERS + ${${CURRENT_PROJECT_NAME}_PUBLIC_HEADERS} + ${${CURRENT_PROJECT_NAME}_UNGROUPED_SOURCES}) + +list(APPEND ${CURRENT_PROJECT_NAME}_SOURCES + ${${CURRENT_PROJECT_NAME}_UNGROUPED_SOURCES}) + +cm_setup_version(VERSION 0.1.0 PREFIX ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}) + +add_library(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE) + +set_target_properties(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} PROPERTIES + EXPORT_NAME ${CURRENT_PROJECT_NAME}) + +target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE + epoll-shim + ${CMAKE_WORKSPACE_NAME}::network + ${CMAKE_WORKSPACE_NAME}::core + + crypto3::algebra + crypto3::hash + crypto3::containers + + ${Boost_LIBRARIES}) + +target_include_directories(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE + "$" + "$" + + ${Boost_INCLUDE_DIRS}) + +cm_deploy(TARGETS ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INCLUDE include NAMESPACE ${CMAKE_WORKSPACE_NAME}::) + +if (BUILD_TESTS) + add_subdirectory(test) +endif () + +if (BUILD_EXAMPLES) + add_subdirectory(example) +endif () + diff --git a/LICENSE_1_0.txt b/LICENSE_1_0.txt new file mode 100644 index 0000000000..17560bd5e2 --- /dev/null +++ b/LICENSE_1_0.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Mikhail Komarov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000000..18b3bc1752 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Containers for =nil; Foundation's Cryptography Suite + +Containers using =nil; Foundation's cryptography suite. + +## Building + +This library uses Boost CMake build modules (https://github.com/BoostCMake/cmake_modules.git). +To actually include this library in a project it is required to: + +1. Add [CMake Modules](https://github.com/BoostCMake/cmake_modules.git) as submodule to target project repository. +2. Add all the internal dependencies using [CMake Modules](https://github.com/BoostCMake/cmake_modules.git) as submodules to target project repository. +3. Initialize parent project with [CMake Modules](https://github.com/BoostCMake/cmake_modules.git) (Look at [crypto3](https://github.com/nilfoundation/crypto3.git) for the example) + +## Dependencies + +### Internal + +* [Boost.Predef](https://github.com/nilfoundation/predef.git) (until https://github.com/boostorg/predef/pull/108 and https://github.com/boostorg/predef/pull/107 are accepted) +* [Boost.Config](https://github.com/nilfoundation/config.git) (until https://github.com/boostorg/config/pull/338 and https://github.com/boostorg/config/pull/339 are accepted) +* [Hash](https://github.com/nilfoundation/crypto3-hash.git). + +### External +* [Boost](https://boost.org) (>= 1.58) \ No newline at end of file diff --git a/cmake/CheckAVX.cmake b/cmake/CheckAVX.cmake new file mode 100644 index 0000000000..183cb71ef4 --- /dev/null +++ b/cmake/CheckAVX.cmake @@ -0,0 +1,63 @@ +include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) + +set(AVX_CODE " + #include + + int main() + { + __m256 a; + a = _mm256_set1_ps(0); + return 0; + } +") + +set(AVX2_CODE " + #include + + int main() + { + __m256i a = {0}; + a = _mm256_abs_epi16(a); + __m256i x; + _mm256_extract_epi64(x, 0); // we rely on this in our AVX2 code + return 0; + } +") + +macro(check_avx_lang lang type flags) + set(__FLAG_I 1) + set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) + foreach(__FLAG ${flags}) + if(NOT ${lang}_${type}_FOUND) + set(CMAKE_REQUIRED_FLAGS ${__FLAG}) + if(lang STREQUAL "CXX") + check_cxx_source_compiles("${${type}_CODE}" ${lang}_HAS_${type}_${__FLAG_I}) + else() + check_c_source_compiles("${${type}_CODE}" ${lang}_HAS_${type}_${__FLAG_I}) + endif() + if(${lang}_HAS_${type}_${__FLAG_I}) + set(${lang}_${type}_FOUND TRUE CACHE BOOL "${lang} ${type} support") + set(${lang}_${type}_FLAGS "${__FLAG}" CACHE STRING "${lang} ${type} flags") + endif() + math(EXPR __FLAG_I "${__FLAG_I}+1") + endif() + endforeach() + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) + + if(NOT ${lang}_${type}_FOUND) + set(${lang}_${type}_FOUND FALSE CACHE BOOL "${lang} ${type} support") + set(${lang}_${type}_FLAGS "" CACHE STRING "${lang} ${type} flags") + endif() + + mark_as_advanced(${lang}_${type}_FOUND ${lang}_${type}_FLAGS) + +endmacro() + +macro(check_avx) + check_avx_lang(C "AVX" " ;-mavx;/arch:AVX") + check_avx_lang(C "AVX2" " ;-mavx2 -mfma;/arch:AVX2") + + check_avx_lang(CXX "AVX" " ;-mavx;/arch:AVX") + check_avx_lang(CXX "AVX2" " ;-mavx2 -mfma;/arch:AVX2") +endmacro() \ No newline at end of file diff --git a/cmake/CheckSSE.cmake b/cmake/CheckSSE.cmake new file mode 100644 index 0000000000..67e3ab5596 --- /dev/null +++ b/cmake/CheckSSE.cmake @@ -0,0 +1,138 @@ +# Check if SSE instructions are available on the machine where +# the project is compiled. + +macro(check_sse) + if(CMAKE_SYSTEM_NAME MATCHES "Linux") + exec_program(cat ARGS "/proc/cpuinfo" OUTPUT_VARIABLE CPUINFO) + + string(REGEX REPLACE "^.*(sse2).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "sse2" "${SSE_THERE}" SSE2_TRUE) + if(SSE2_TRUE) + set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") + else(SSE2_TRUE) + set(SSE2_FOUND false CACHE BOOL "SSE2 available on host") + endif(SSE2_TRUE) + + # /proc/cpuinfo apparently omits sse3 :( + string(REGEX REPLACE "^.*[^s](sse3).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "sse3" "${SSE_THERE}" SSE3_TRUE) + if(NOT SSE3_TRUE) + string(REGEX REPLACE "^.*(T2300).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "T2300" "${SSE_THERE}" SSE3_TRUE) + endif(NOT SSE3_TRUE) + + string(REGEX REPLACE "^.*(ssse3).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "ssse3" "${SSE_THERE}" SSSE3_TRUE) + if(SSE3_TRUE OR SSSE3_TRUE) + set(SSE3_FOUND true CACHE BOOL "SSE3 available on host") + else(SSE3_TRUE OR SSSE3_TRUE) + set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") + endif(SSE3_TRUE OR SSSE3_TRUE) + if(SSSE3_TRUE) + set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host") + else(SSSE3_TRUE) + set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") + endif(SSSE3_TRUE) + + string(REGEX REPLACE "^.*(sse4_1).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "sse4_1" "${SSE_THERE}" SSE41_TRUE) + if(SSE41_TRUE) + set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host") + else(SSE41_TRUE) + set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") + endif(SSE41_TRUE) + + string(REGEX REPLACE "^.*(sse4_2).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "sse4_2" "${SSE_THERE}" SSE42_TRUE) + if(SSE42_TRUE) + set(SSE4_2_FOUND true CACHE BOOL "SSE4.2 available on host") + else(SSE42_TRUE) + set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host") + endif(SSE42_TRUE) + + elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") + exec_program("/usr/sbin/sysctl -n machdep.cpu.features" OUTPUT_VARIABLE + CPUINFO) + + string(REGEX REPLACE "^.*[^S](SSE2).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "SSE2" "${SSE_THERE}" SSE2_TRUE) + if(SSE2_TRUE) + set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") + else(SSE2_TRUE) + set(SSE2_FOUND false CACHE BOOL "SSE2 available on host") + endif(SSE2_TRUE) + + string(REGEX REPLACE "^.*[^S](SSE3).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "SSE3" "${SSE_THERE}" SSE3_TRUE) + if(SSE3_TRUE) + set(SSE3_FOUND true CACHE BOOL "SSE3 available on host") + else(SSE3_TRUE) + set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") + endif(SSE3_TRUE) + + string(REGEX REPLACE "^.*(SSSE3).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "SSSE3" "${SSE_THERE}" SSSE3_TRUE) + if(SSSE3_TRUE) + set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host") + else(SSSE3_TRUE) + set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") + endif(SSSE3_TRUE) + + string(REGEX REPLACE "^.*(SSE4.1).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "SSE4.1" "${SSE_THERE}" SSE41_TRUE) + if(SSE41_TRUE) + set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host") + else(SSE41_TRUE) + set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") + endif(SSE41_TRUE) + + string(REGEX REPLACE "^.*(SSE4.2).*$" "\\1" SSE_THERE ${CPUINFO}) + string(COMPARE EQUAL "SSE4.2" "${SSE_THERE}" SSE42_TRUE) + if(SSE42_TRUE) + set(SSE4_2_FOUND true CACHE BOOL "SSE4.2 available on host") + else(SSE42_TRUE) + set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host") + endif(SSE42_TRUE) + + elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") + # TODO + set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") + set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") + set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") + set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") + set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host") + else(CMAKE_SYSTEM_NAME MATCHES "Linux") + set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") + set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") + set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") + set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") + set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host") + endif(CMAKE_SYSTEM_NAME MATCHES "Linux") + + if(CMAKE_COMPILER_IS_GNUCXX) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) + if(GCC_VERSION VERSION_LESS 4.2) + set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host" FORCE) + set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host" FORCE) + endif() + endif(CMAKE_COMPILER_IS_GNUCXX) + + if(NOT SSE2_FOUND) + message(STATUS "Could not find support for SSE2 on this machine.") + endif(NOT SSE2_FOUND) + if(NOT SSE3_FOUND) + message(STATUS "Could not find support for SSE3 on this machine.") + endif(NOT SSE3_FOUND) + if(NOT SSSE3_FOUND) + message(STATUS "Could not find support for SSSE3 on this machine.") + endif(NOT SSSE3_FOUND) + if(NOT SSE4_1_FOUND) + message(STATUS "Could not find support for SSE4.1 on this machine.") + endif(NOT SSE4_1_FOUND) + if(NOT SSE4_2_FOUND) + message(STATUS "Could not find support for SSE4.2 on this machine.") + endif(NOT SSE4_2_FOUND) + + mark_as_advanced(SSE2_FOUND SSE3_FOUND SSSE3_FOUND SSE4_1_FOUND SSE4_2_FOUND) + +endmacro(check_sse) \ No newline at end of file diff --git a/cmake/PlatformConfiguration.cmake b/cmake/PlatformConfiguration.cmake new file mode 100644 index 0000000000..403f015b9a --- /dev/null +++ b/cmake/PlatformConfiguration.cmake @@ -0,0 +1,141 @@ +include(CheckTypeSize) + +function(define_target_architecture prefix_name target_architecture) + string(TOUPPER ${target_architecture} UPPER_TARGET_ARCHITECTURE) + string(TOUPPER ${prefix_name} UPPER_PREFIX_NAME) + + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_ARCHITECTURE_IS_${UPPER_TARGET_ARCHITECTURE}) +endfunction() + +function(define_target_endianness prefix_name target_architecture) + string(TOUPPER ${target_architecture} UPPER_TARGET_ARCHITECTURE) + string(TOUPPER ${prefix_name} UPPER_PREFIX_NAME) + + if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64") + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_X86_FAMILY) + elseif(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV8" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV7S" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV6" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV5" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM32" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV7") + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_ARM_FAMILY) + elseif(${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64") + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_PPC_FAMILY) + endif() + + if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ALPHA" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV8" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV7S" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV6" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV5" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM32" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV7" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64") + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_LITTLE_ENDIAN) + elseif(${UPPER_TARGET_ARCHITECTURE} STREQUAL "M68K" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390X" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC32" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64") + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_BIG_ENDIAN) + endif() +endfunction() + +function(define_target_platform_size prefix_name target_architecture) + string(TOUPPER ${target_architecture} UPPER_TARGET_ARCHITECTURE) + string(TOUPPER ${prefix_name} UPPER_PREFIX_NAME) + + if(${CMAKE_TARGET_ARCHITECTURE} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR}) + # check_type_size(int CMAKE_TARGET_INTEGER_SIZE_BYTE) + # math(EXPR CMAKE_TARGET_INTEGER_SIZE_BITS "${CMAKE_TARGET_INTEGER_SIZE_BYTE} * 8") + # add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=${CMAKE_TARGET_INTEGER_SIZE_BITS}) + + if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ALPHA" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390X") + add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=64) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_HAS_NATIVE_64BIT) + else() + add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=32) + endif() + else() + if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ALPHA" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64" OR + ${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390X") + add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=64) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_HAS_NATIVE_64BIT) + else() + add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=32) + endif() + endif() + + if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64") + add_definitions(-D${UPPER_PREFIX_NAME}_MP_USE_X86_64_ASM) + elseif(${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86") + add_definitions(-D${UPPER_PREFIX_NAME}_MP_USE_X86_32_ASM) + endif() +endfunction() + +function(define_target_platform_features prefix_name) + include(CheckSymbolExists) + + string(TOUPPER ${prefix_name} UPPER_PREFIX_NAME) + + if(UNIX) + if(APPLE) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_IS_DARWIN) + + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_ARC4RANDOM) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_MEMSET_S) + else() + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_CLOCK_GETTIME) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_POSIX_MLOCK) + endif() + + check_symbol_exists(clock_gettime sys/time.h HAVE_CLOCK_GETTIME) + check_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) + + if(HAVE_GETTIMEOFDAY) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_GETTIMEOFDAY) + endif() + + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_TYPE_IS_UNIX) + + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_GMTIME_R) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_DEV_RANDOM) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_POSIX1) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_FILELSYSTEM) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_TIMEGM) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_SOCKETS) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_READDIR) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_DLOPEN) + elseif(WIN32) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_TYPE_IS_WINDOWS) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_WIN32) + + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_RTLGENRANDOM) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_GMTIME_S) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_LOADLIBRARY) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_MKGMTIME) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_QUERY_PREF_COUNTER) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_VIRTUAL_LOCK) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_RTLSECUREZEROMEMORY) + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_STL_FILESYSTEM_MSVC) + endif() + + add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_THREADS) +endfunction() \ No newline at end of file diff --git a/cmake/TargetArchitecture.cmake b/cmake/TargetArchitecture.cmake new file mode 100644 index 0000000000..afaaa7274f --- /dev/null +++ b/cmake/TargetArchitecture.cmake @@ -0,0 +1,163 @@ + +# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h +# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) + +# Regarding POWER/PowerPC, just as is noted in the Qt source, +# "There are many more known variants/revisions that we do not handle/detect." + +set(archdetect_c_code " +#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) + #if defined(__ARM64_ARCH_8__) + #error cmake_ARCH armv8 + #elif defined(__aarch64__) + #error cmake_ARCH arm64 + #elif defined(__ARM_ARCH_7__) \\ + || defined(__ARM_ARCH_7A__) \\ + || defined(__ARM_ARCH_7R__) \\ + || defined(__ARM_ARCH_7M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) + #error cmake_ARCH armv7 + #elif defined(__ARM_ARCH_7S__) + #error cmake_ARCH armv7s + #elif defined(__ARM_ARCH_6__) \\ + || defined(__ARM_ARCH_6J__) \\ + || defined(__ARM_ARCH_6T2__) \\ + || defined(__ARM_ARCH_6Z__) \\ + || defined(__ARM_ARCH_6K__) \\ + || defined(__ARM_ARCH_6ZK__) \\ + || defined(__ARM_ARCH_6M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) + #error cmake_ARCH armv6 + #elif defined(__ARM_ARCH_5TEJ__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) + #error cmake_ARCH armv5 + #else + #error cmake_ARCH arm32 + #endif +#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) + #error cmake_ARCH i386 +#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) + #error cmake_ARCH x86_64 +#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) + #error cmake_ARCH ia64 +#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ + || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ + || defined(_M_MPPC) || defined(_M_PPC) + #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) + #error cmake_ARCH ppc64 + #else + #error cmake_ARCH ppc + #endif +#elif defined(__mips__) || defined(__mips) + #if defined(__LP64__) || defined(_LP64) + #error cmake_ARCH mips64 + #else + #error cmake_ARCH mips32 + #endif +#elif defined(__sparc__) + #if defined(__LP64__) || defined(_LP64) + #error cmake_ARCH sparc64 + #else + #error cmake_ARCH sparc32 + #endif +#elif defined(__alpha__) + #error cmake_ARCH alpha +#elif defined(__hppa__) || defined(__hppa) + #error cmake_ARCH hppa +#elif defined(__m68k__) + #error cmake_ARCH m68k +#elif defined(__sh__) + #error cmake_ARCH sh +#elif defined(__s390x__) + #error cmake_ARCH s390x +#elif defined(__s390__) + #error cmake_ARCH s390 +#endif + +#error cmake_ARCH unknown +") + +# Set ppc_support to TRUE before including this file or ppc and ppc64 +# will be treated as invalid architectures since they are no longer supported by Apple + +function(target_architecture OUTPUT_ARCHITECTURE) + if(APPLE AND CMAKE_OSX_ARCHITECTURES) + # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set + # First let's normalize the order of the values + + # Note that it's not possible to compile PowerPC applications if you are using + # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we + # disable it by default + # See this page for more information: + # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 + + # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. + # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. + + foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) + if("${osx_arch}" STREQUAL "ppc" AND ppc_support) + set(osx_arch_ppc TRUE) + elseif("${osx_arch}" STREQUAL "i386") + set(osx_arch_i386 TRUE) + elseif("${osx_arch}" STREQUAL "x86_64") + set(osx_arch_x86_64 TRUE) + elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) + set(osx_arch_ppc64 TRUE) + else() + message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") + endif() + endforeach() + + # Now add all the architectures in our normalized order + if(osx_arch_ppc) + list(APPEND ARCH ppc) + endif() + + if(osx_arch_i386) + list(APPEND ARCH i386) + endif() + + if(osx_arch_x86_64) + list(APPEND ARCH x86_64) + endif() + + if(osx_arch_ppc64) + list(APPEND ARCH ppc64) + endif() + else() + file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") + + enable_language(C) + + # Detect the architecture in a rather creative way... + # This compiles a small C program which is a series of ifdefs that selects a + # particular #error preprocessor directive whose message string contains the + # target architecture. The program will always fail to compile (both because + # file is not a valid C program, and obviously because of the presence of the + # #error preprocessor directives... but by exploiting the preprocessor in this + # way, we can detect the correct target architecture even when cross-compiling, + # since the program itself never needs to be run (only the compiler/preprocessor) + try_run(run_result_unused + compile_result_unused + "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}/arch.c" + COMPILE_OUTPUT_VARIABLE RESULT_ARCH + CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + ) + + # Parse the architecture name from the compiler output + string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${RESULT_ARCH}") + + # Get rid of the value marker leaving just the architecture name + string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") + + # If we are compiling with an unknown architecture this variable should + # already be set to "unknown" but in the case that it's empty (i.e. due + # to a typo in the code), then set it to unknown + if(NOT ARCH) + set(ARCH unknown) + endif() + endif() + + set(${OUTPUT_ARCHITECTURE} "${ARCH}" PARENT_SCOPE) +endfunction() diff --git a/cmake/TargetConfiguration.cmake b/cmake/TargetConfiguration.cmake new file mode 100644 index 0000000000..f72ff9bbb2 --- /dev/null +++ b/cmake/TargetConfiguration.cmake @@ -0,0 +1,6 @@ +macro(define_current_target target_name project_name) + set(CMAKE_CURRENT_TARGET ${target_name}) + string(TOUPPER ${target_name} CMAKE_UPPER_CURRENT_TARGET) + string(TOUPPER ${project_name} CMAKE_UPPER_PROJECT_NAME) + add_definitions(-D${CMAKE_UPPER_PROJECT_NAME}_HAS_${CMAKE_UPPER_CURRENT_TARGET}) +endmacro() \ No newline at end of file diff --git a/cmake/architectures/alpha.json b/cmake/architectures/alpha.json new file mode 100644 index 0000000000..72c50e871d --- /dev/null +++ b/cmake/architectures/alpha.json @@ -0,0 +1,8 @@ +{ + "endian": "little", + "word_size": 64, + "aliases": [ + "axp", + "alphaaxp" + ] +} diff --git a/cmake/architectures/arm32.json b/cmake/architectures/arm32.json new file mode 100644 index 0000000000..9f7934c8cf --- /dev/null +++ b/cmake/architectures/arm32.json @@ -0,0 +1,16 @@ +{ + "endian": "little", + "family": "arm", + "aliases": [ + "arm", + "armeb", + "armel", + "armhf", + "evbarm", + "armv7", + "armv7l", + "armv7-a", + "armv8l" + ], + "isa_Extensions": "neon" +} diff --git a/cmake/architectures/arm64.json b/cmake/architectures/arm64.json new file mode 100644 index 0000000000..dfb28913cc --- /dev/null +++ b/cmake/architectures/arm64.json @@ -0,0 +1,19 @@ +{ + "endian": "little", + "word_size": 64, + "family": "arm", + "aliases": [ + "aarch64", + "armv8", + "armv8-a", + "arm64" + ], + "isa_extensions": [ + "neon", + "armv8crypto", + "armv8sm3", + "armv8sm4", + "armv8sha3", + "armv8sha512" + ] +} diff --git a/cmake/architectures/hppa.json b/cmake/architectures/hppa.json new file mode 100644 index 0000000000..87aedf039a --- /dev/null +++ b/cmake/architectures/hppa.json @@ -0,0 +1,12 @@ +{ + "word_size": 64, + "endian": "little", + "aliases": [ + "hp-pa", + "parisc", + "parisc64", + "pa-risc", + "hp-parisc", + "hp-pa-risc" + ] +} diff --git a/cmake/architectures/ia64.json b/cmake/architectures/ia64.json new file mode 100644 index 0000000000..a71d2b51d4 --- /dev/null +++ b/cmake/architectures/ia64.json @@ -0,0 +1,7 @@ +{ + "word_size": 64, + "aliases": [ + "itanium", + "itanic" + ] +} diff --git a/cmake/architectures/llvm.json b/cmake/architectures/llvm.json new file mode 100644 index 0000000000..cb382a5fae --- /dev/null +++ b/cmake/architectures/llvm.json @@ -0,0 +1,4 @@ +{ + "word_size": 64, + "endian": "little" +} diff --git a/cmake/architectures/m68k.json b/cmake/architectures/m68k.json new file mode 100644 index 0000000000..d5d2b9c8d2 --- /dev/null +++ b/cmake/architectures/m68k.json @@ -0,0 +1,8 @@ +{ + "word_size": 32, + "endian": "big", + "aliases": [ + "680x0", + "68k" + ] +} diff --git a/cmake/architectures/mips32.json b/cmake/architectures/mips32.json new file mode 100644 index 0000000000..1742654d4b --- /dev/null +++ b/cmake/architectures/mips32.json @@ -0,0 +1,10 @@ +{ + "word_size": 32, + "endian": "little", + "aliases": [ + "mips", + "mipsbe", + "mipsle", + "mipsel" + ] +} diff --git a/cmake/architectures/mips64.json b/cmake/architectures/mips64.json new file mode 100644 index 0000000000..4d5cbdb86d --- /dev/null +++ b/cmake/architectures/mips64.json @@ -0,0 +1,7 @@ +{ + "word_size": 64, + "endian": "little", + "aliases": [ + "mips64el" + ] +} \ No newline at end of file diff --git a/cmake/architectures/powerpcspe.json b/cmake/architectures/powerpcspe.json new file mode 100644 index 0000000000..79ba6c9b54 --- /dev/null +++ b/cmake/architectures/powerpcspe.json @@ -0,0 +1,5 @@ +{ + "word_size": 32, + "endian": "big", + "family": "ppc" +} diff --git a/cmake/architectures/ppc32.json b/cmake/architectures/ppc32.json new file mode 100644 index 0000000000..96d76ef168 --- /dev/null +++ b/cmake/architectures/ppc32.json @@ -0,0 +1,12 @@ +{ + "word_size": 32, + "endian": "big", + "family": "ppc", + "aliases": [ + "powerpc", + "ppc" + ], + "isa_extensions": [ + "altivec" + ] +} diff --git a/cmake/architectures/ppc64.json b/cmake/architectures/ppc64.json new file mode 100644 index 0000000000..a617f52fd8 --- /dev/null +++ b/cmake/architectures/ppc64.json @@ -0,0 +1,15 @@ +{ + "endian": "big", + "word_size": 64, + "family": "ppc", + "aliases": [ + "powerpc64", + "powerpc64le", + "ppc64le", + "ppc64el" + ], + "isa_extensions": [ + "altivec", + "ppccrypto" + ] +} \ No newline at end of file diff --git a/cmake/architectures/riscv64.json b/cmake/architectures/riscv64.json new file mode 100644 index 0000000000..f64ec22e32 --- /dev/null +++ b/cmake/architectures/riscv64.json @@ -0,0 +1,5 @@ +{ + "endian": "little", + "word_size": 32, + "family": "riscv" +} \ No newline at end of file diff --git a/cmake/architectures/s390.json b/cmake/architectures/s390.json new file mode 100644 index 0000000000..690902f193 --- /dev/null +++ b/cmake/architectures/s390.json @@ -0,0 +1,4 @@ +{ + "word_size": 32, + "endian": "big" +} \ No newline at end of file diff --git a/cmake/architectures/s390x.json b/cmake/architectures/s390x.json new file mode 100644 index 0000000000..b5e5afbe66 --- /dev/null +++ b/cmake/architectures/s390x.json @@ -0,0 +1,4 @@ +{ + "endian": "big", + "word_size": 64 +} \ No newline at end of file diff --git a/cmake/architectures/sparc32.json b/cmake/architectures/sparc32.json new file mode 100644 index 0000000000..0e74eb2bcd --- /dev/null +++ b/cmake/architectures/sparc32.json @@ -0,0 +1,8 @@ +{ + "endian": "big", + "word_size": 32, + "family": "sparc", + "aliases": [ + "sparc" + ] +} \ No newline at end of file diff --git a/cmake/architectures/sparc64.json b/cmake/architectures/sparc64.json new file mode 100644 index 0000000000..7c8bd96162 --- /dev/null +++ b/cmake/architectures/sparc64.json @@ -0,0 +1,5 @@ +{ + "endian": "big", + "word_size": 64, + "family": "sparc" +} \ No newline at end of file diff --git a/cmake/architectures/superh.json b/cmake/architectures/superh.json new file mode 100644 index 0000000000..1cf2aad84a --- /dev/null +++ b/cmake/architectures/superh.json @@ -0,0 +1,7 @@ +{ + "endian": "little", + "word_size": 32, + "aliases": [ + "sh4" + ] +} diff --git a/cmake/architectures/x32.json b/cmake/architectures/x32.json new file mode 100644 index 0000000000..8191cd0c4a --- /dev/null +++ b/cmake/architectures/x32.json @@ -0,0 +1,17 @@ +{ + "endian": "little", + "word_size": 32, + "family": "x86", + "isa_extensions": [ + "aesni", + "avx2", + "bmi2", + "rdrand", + "rdseed", + "sha", + "sse2", + "sse41", + "sse42", + "ssse3" + ] +} diff --git a/cmake/architectures/x86_32.json b/cmake/architectures/x86_32.json new file mode 100644 index 0000000000..c41102b432 --- /dev/null +++ b/cmake/architectures/x86_32.json @@ -0,0 +1,30 @@ +{ + "endian": "little", + "word_size": 32, + "family": "x86", + "aliases": [ + "ia32", + "x86", + "ix86", + "80x86", + "i86pc", + "x86pc", + "bepc", + "i686-at386", + "i686", + "i586", + "i386" + ], + "isa_extensions": [ + "aesni", + "avx2", + "bmi2", + "rdrand", + "rdseed", + "sha", + "sse2", + "sse41", + "sse42", + "ssse3" + ] +} diff --git a/cmake/architectures/x86_64.json b/cmake/architectures/x86_64.json new file mode 100644 index 0000000000..f5608179c2 --- /dev/null +++ b/cmake/architectures/x86_64.json @@ -0,0 +1,24 @@ +{ + "endian": "little", + "word_size": 64, + "family": "x86", + "aliases": [ + "amd64", + "x86-64", + "em64t", + "x64", + "x86_amd64" + ], + "isa_extensions": [ + "aesni", + "avx2", + "bmi2", + "rdrand", + "rdseed", + "sha", + "sse2", + "sse41", + "sse42", + "ssse3" + ] +} \ No newline at end of file diff --git a/cmake/modules/.gitattributes b/cmake/modules/.gitattributes new file mode 100644 index 0000000000..1c9df89903 --- /dev/null +++ b/cmake/modules/.gitattributes @@ -0,0 +1,3 @@ +* text=auto +*.bat text eol=crlf +Makefile text eol=lf diff --git a/cmake/modules/.travis.yml b/cmake/modules/.travis.yml new file mode 100644 index 0000000000..fe2afb47df --- /dev/null +++ b/cmake/modules/.travis.yml @@ -0,0 +1,50 @@ +sudo: required +dist: trusty +language: cpp +script: cmake + +matrix: + include: + # OSX + - os: osx + compiler: clang + + - os: linux + compiler: gcc + addons: &gcc + apt: + packages: + - util-linux + - g++-4.9 + sources: + - ubuntu-toolchain-r-test + +install: + - export CHECKOUT_PATH=`pwd` + # Setup deps directory + - export DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" + - mkdir ${DEPS_DIR} && cd ${DEPS_DIR} + - mkdir usr + - export PATH=${DEPS_DIR}/usr/bin:${PATH} + # Install cmake + - CMAKE_URL="http://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz" + - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C usr; fi + # Show compiler info + - $CXX --version + - which $CXX + - $CC --version + - which $CC + - which cmake + - cmake --version + +script: + - export INSTALL_PREFIX_PATH="${TRAVIS_BUILD_DIR}/usr" + - mkdir -p "$INSTALL_PREFIX_PATH" + - cd $CHECKOUT_PATH + - mkdir build + - cd build + - cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX_PATH .. + - make check + - make install + - rm -rf "$INSTALL_PREFIX_PATH" + diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt new file mode 100644 index 0000000000..b0b03fa21c --- /dev/null +++ b/cmake/modules/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 3.5) + +install(DIRECTORY share/modules/cmake DESTINATION cm) + +enable_testing() +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR}) +add_subdirectory(test) diff --git a/cmake/modules/README.md b/cmake/modules/README.md new file mode 100644 index 0000000000..07b26b29ac --- /dev/null +++ b/cmake/modules/README.md @@ -0,0 +1,29 @@ +CMake Modules +============= +[![Build Status](https://travis-ci.com/BoostCMake/cmake_modules.svg?branch=master)](https://travis-ci.com/BoostCMake/cmake_modules) [![Build status](https://ci.appveyor.com/api/projects/status/f3qe31c4hd7iwumn/branch/master?svg=true)](https://ci.appveyor.com/project/nemo1369/cmake-modules/branch/master) + +Motivation +---------- + +This provides cmake modules suitable for in-project and in-repository dependencies management. It provides modules to reduce the boilerplate for installing, versioning, setting up package config, and creating tests. + +Usage +----- + +The modules can be installed using standard cmake install: + + mkdir build + cd build + cmake .. + cmake --build . --target install + +Once installed, the modules can be used by using `find_package` and then including the appropriate module: + + find_package(CM) + include(CMPackage) + +Documentation +------------- + +http://bcm.readthedocs.io + diff --git a/cmake/modules/appveyor.yml b/cmake/modules/appveyor.yml new file mode 100644 index 0000000000..4b061b7aa3 --- /dev/null +++ b/cmake/modules/appveyor.yml @@ -0,0 +1,38 @@ + +os: Visual Studio 2015 + +environment: + matrix: + # - GENERATOR: "Visual Studio 14 2015 Win64" + # CONFIG: Debug + + # - GENERATOR: "Visual Studio 14 2015 Win64" + # CONFIG: Release + + - GENERATOR: "Visual Studio 14 2015" + CONFIG: Debug + + # - GENERATOR: "Visual Studio 14 2015" + # CONFIG: Release + +matrix: + fast_finish: true + +install: + # Install pkg-config from chocolatey + - cinst pkgconfiglite + +build_script: + - cmd: set PATH=C:\Program Files (x86)\CMake\bin;%PATH% + - cmd: set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH% + - cmd: call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat" + - cmd: set CTEST_OUTPUT_ON_FAILURE=1 + - cmd: cmake --version + - cmd: mkdir build + - cmd: cd build + - cmd: cmake .. -G"%GENERATOR%" + - cmd: cmake --build . --config %CONFIG% --target check + +# test_script: +# - cmd: ctest -C Debug --output-on-failure +# - cmd: cd ../../ \ No newline at end of file diff --git a/cmake/modules/doc/conf.py b/cmake/modules/doc/conf.py new file mode 100644 index 0000000000..eaeee30c0a --- /dev/null +++ b/cmake/modules/doc/conf.py @@ -0,0 +1,333 @@ +# -*- coding: utf-8 -*- +# +# modules documentation build configuration file, created by +# sphinx-quickstart on Tue Jan 10 00:08:48 2017. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) +import sphinx_boost + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +# +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'modules' +copyright = u'2017, Paul Fultz II' +author = u'Paul Fultz II' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'0.1' +# The full version, including alpha/beta/rc tags. +release = u'0.1' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# +# today = '' +# +# Else, today_fmt is used as the format for a strftime call. +# +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'tango' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'boost' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +html_theme_path = [sphinx_boost.get_html_theme_path()] + +# The name for this set of Sphinx documents. +# " v documentation" by default. +# +# html_title = u'modules v0.1' + +# A shorter title for the navigation bar. Default is the same as html_title. +# +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# +html_logo = 'boost-proposed.png' + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# +# html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +# +# html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# +# html_additional_pages = {} + +# If false, no module index is generated. +# +# html_domain_indices = True + +# If false, no index is generated. +# +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' +# +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +# +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'bcmdoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'modules.tex', u'modules Documentation', + u'Paul Fultz II', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# +# latex_use_parts = False + +# If true, show page references after internal links. +# +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# +# latex_appendices = [] + +# If false, no module index is generated. +# +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'modules', u'modules Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +# +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'modules', u'modules Documentation', + author, 'modules', 'Boost cmake modules', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# +# texinfo_appendices = [] + +# If false, no module index is generated. +# +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# +# texinfo_no_detailmenu = False diff --git a/cmake/modules/doc/index.rst b/cmake/modules/doc/index.rst new file mode 100644 index 0000000000..c223e01120 --- /dev/null +++ b/cmake/modules/doc/index.rst @@ -0,0 +1,14 @@ +.. _contents: + +CMakeModules +=== + +**Mikhail Komarov** + +.. toctree:: + :maxdepth: 3 + + src/Intro + src/Building + src/Modules + diff --git a/cmake/modules/doc/make.bat b/cmake/modules/doc/make.bat new file mode 100644 index 0000000000..07e686b6b2 --- /dev/null +++ b/cmake/modules/doc/make.bat @@ -0,0 +1,281 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. epub3 to make an epub3 + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + echo. coverage to run coverage check of the documentation if enabled + echo. dummy to check syntax errors of document sources + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +REM Check if sphinx-build is available and fallback to Python version if any +%SPHINXBUILD% 1>NUL 2>NUL +if errorlevel 9009 goto sphinx_python +goto sphinx_ok + +:sphinx_python + +set SPHINXBUILD=python -m sphinx.__init__ +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +:sphinx_ok + + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\bcm.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\bcm.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "epub3" ( + %SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3 + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub3 file is in %BUILDDIR%/epub3. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "coverage" ( + %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage + if errorlevel 1 exit /b 1 + echo. + echo.Testing of coverage in the sources finished, look at the ^ +results in %BUILDDIR%/coverage/python.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +if "%1" == "dummy" ( + %SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. Dummy builder generates no files. + goto end +) + +:end diff --git a/cmake/modules/doc/requirements.txt b/cmake/modules/doc/requirements.txt new file mode 100644 index 0000000000..6e052bd53c --- /dev/null +++ b/cmake/modules/doc/requirements.txt @@ -0,0 +1,2 @@ +sphinx +sphinx-boost>0.0.2 \ No newline at end of file diff --git a/cmake/modules/doc/src/Building.rst b/cmake/modules/doc/src/Building.rst new file mode 100644 index 0000000000..7a9880cc7c --- /dev/null +++ b/cmake/modules/doc/src/Building.rst @@ -0,0 +1,319 @@ +======== +Building +======== + +There are two scenarios where the users will consume their dependencies in the build: + +* Prebuilt binaries using ``find_package`` +* Integrated builds using ``add_subdirectory`` + +When we build libraries using cmake, we want to be able to support both scenarios. + +The first scenario the user would build and install each dependency. With this scenario, we need to generate usage requirements that can be consumed by the user, and ultimately this is done through cmake's ``find_package`` mechanism. + +In the integrated build scenario, the user adds the sources with ``add_subdirectory``, and then all dependencies are built in the user's build. There is no need to generate usage requirements as the cmake targets are directly available in the build. + +Let's first look at standalone build. + +------------------------------ +Building standalone with cmake +------------------------------ + +Let's look at building a library like Boost.Filesystem using just cmake. When we start a cmake, we start with minimuim requirement and the project name:: + + cmake_minimum_required(VERSION 3.5) + project(boost_filesystem) + +Then we can define the library and the sources it will build:: + + add_library(boost_filesystem + src/operations.cpp + src/portability.cpp + src/codecvt_error_category.cpp + src/utf8_codecvt_facet.cpp + src/windows_file_codecvt.cpp + src/unique_path.cpp + src/path.cpp + src/path_traits.cpp + ) + +So this will build the library named ``boost_filesystem``, however, we need to supply the dependencies to ``boost_filesystem`` and add the include directories. To add the include directory we use ``target_include_directories``. For this, we tell cmake to use local ``include`` directory, but since this is only valid during build and not after installation, we use the ``BUILD_INTERFACE`` generator expression so that cmake will only use it during build and not installation:: + + target_include_directories(boost_filesystem PUBLIC + $ + ) + +Using ``PUBLIC`` means this include directory will be used internally to build, and downstream users need this include as well. Next, we need to pull in the dependencies. To do this, we call ``find_package``, and for the sake of the turtorial we assume that the upstream boost libraries have already set this up:: + + find_package(boost_core) + find_package(boost_static_assert) + find_package(boost_iterator) + find_package(boost_detail) + find_package(boost_system) + find_package(boost_functional) + find_package(boost_assert) + find_package(boost_range) + find_package(boost_type_traits) + find_package(boost_smart_ptr) + find_package(boost_io) + find_package(boost_config) + +Calling ``find_package`` will find those libraries and provide a target we can use to link against. The next step is to link it using ``target_link_libraries``:: + + target_link_libraries(boost_filesystem PUBLIC + boost::core + boost::static_assert + boost::iterator + boost::detail + boost::system + boost::functional + boost::assert + boost::range + boost::type_traits + boost::smart_ptr + boost::io + boost::config + ) + +Now, some of these libraries are header-only, but when we call ``target_link_libraries`` it will add all the flags necessary to use those libraries. Next step is installation, using the ``install`` command:: + + install(DIRECTORY include/ DESTINATION include) + + install(TARGETS boost_filesystem EXPORT boost_filesystem-targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + INCLUDES DESTINATION include + ) + +So this will install the include directories and install the library. The ``EXPORT`` command will have cmake generate an export file that will create the target's usage requirements in cmake. This will enable the target to be used by downstream libraries, just like we used ```boost::system``. However, this will only tells cmake which targets are in the export file. To generate it we use ``install(EXPORT)``:: + + install(EXPORT boost_filesystem-targets + FILE boost_filesystem-targets.cmake + NAMESPACE boost:: + DESTINATION lib/cmake/boost_filesystem + ) + +This sets a namespace ``boost::`` on the target, but our target is named ``boost_filesystem``, and we want the exported target to be ``boost::filesystem`` not ``boost::boost_filesystem``. We can do that by setting the export name:: + + set_property(TARGET boost_filesystem PROPERTY EXPORT_NAME filesystem) + +We can also define a target alias to ``boost::filesystem``, which helps integrated builds:: + + add_library(boost::filesystem ALIAS boost_filesystem) + +So now have exported targets we want to generate a ``boost_filesystem-config.cmake`` file so it can be used with ``find_package(boost_filesystem)``. To do this we generate a file the includes the export file, but it also calls ``find_dependency`` on each dependency so that the user does not have to call it:: + + file(WRITE "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" " + include(CMakeFindDependencyMacro) + find_dependency(boost_core) + find_dependency(boost_static_assert) + find_dependency(boost_iterator) + find_dependency(boost_detail) + find_dependency(boost_system) + find_dependency(boost_functional) + find_dependency(boost_assert) + find_dependency(boost_range) + find_dependency(boost_type_traits) + find_dependency(boost_smart_ptr) + find_dependency(boost_io) + find_dependency(boost_config) + include(\"\${CMAKE_CURRENT_LIST_DIR}/boost_filesystem-targets.cmake\") + ") + +Besides the ``boost_filesystem-config.cmake``, we also need a version file to check compatibility. This can be done using cmake's ``write_basic_package_version_file`` function:: + + write_basic_package_version_file("${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" + VERSION 1.64 + COMPATIBILITY AnyNewerVersion + ) + +Then finally we install these files:: + + install(FILES + "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" + "${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" + DESTINATION lib/cmake/boost_filesystem + ) + +Putting it all together we have a cmake file that looks like this:: + + cmake_minimum_required(VERSION 3.5) + project(boost_filesystem) + include(CMakePackageConfigHelpers) + + find_package(boost_core) + find_package(boost_static_assert) + find_package(boost_iterator) + find_package(boost_detail) + find_package(boost_system) + find_package(boost_functional) + find_package(boost_assert) + find_package(boost_range) + find_package(boost_type_traits) + find_package(boost_smart_ptr) + find_package(boost_io) + find_package(boost_config) + + add_library(boost_filesystem + src/operations.cpp + src/portability.cpp + src/codecvt_error_category.cpp + src/utf8_codecvt_facet.cpp + src/windows_file_codecvt.cpp + src/unique_path.cpp + src/path.cpp + src/path_traits.cpp + ) + add_library(boost::filesystem ALIAS boost_filesystem) + set_property(TARGET boost_filesystem PROPERTY EXPORT_NAME filesystem) + + target_include_directories(boost_filesystem PUBLIC + $ + ) + target_link_libraries(boost_filesystem PUBLIC + boost::core + boost::static_assert + boost::iterator + boost::detail + boost::system + boost::functional + boost::assert + boost::range + boost::type_traits + boost::smart_ptr + boost::io + boost::config + ) + + + install(DIRECTORY include/ DESTINATION include) + + install(TARGETS boost_filesystem EXPORT boost_filesystem-targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + INCLUDES DESTINATION include + ) + + install(EXPORT boost_filesystem-targets + FILE boost_filesystem-targets.cmake + NAMESPACE boost:: + DESTINATION lib/cmake/boost_filesystem + ) + + file(WRITE "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" " + include(CMakeFindDependencyMacro) + find_dependency(boost_core) + find_dependency(boost_static_assert) + find_dependency(boost_iterator) + find_dependency(boost_detail) + find_dependency(boost_system) + find_dependency(boost_functional) + find_dependency(boost_assert) + find_dependency(boost_range) + find_dependency(boost_type_traits) + find_dependency(boost_smart_ptr) + find_dependency(boost_io) + find_dependency(boost_config) + include(\"\${CMAKE_CURRENT_LIST_DIR}/boost_filesystem-targets.cmake\") + ") + + write_basic_package_version_file("${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" + VERSION 1.64 + COMPATIBILITY AnyNewerVersion + ) + + install(FILES + "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" + "${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" + DESTINATION lib/cmake/boost_filesystem + ) + +--------------------------- +Building standalone with CM +--------------------------- + +The boost cmake modules can help reduce the boilerplate needed in writing these libraries. To use these modules we just call ``find_package(CM)`` first:: + + cmake_minimum_required(VERSION 3.5) + project(boost_filesystem) + find_package(CM) + +Next we can setup the version for the project using ``cm_setup_version``:: + + cm_setup_version(VERSION 1.64) + +Next, we add the library and link against the dependencies like always:: + + find_package(boost_core) + find_package(boost_static_assert) + find_package(boost_iterator) + find_package(boost_detail) + find_package(boost_system) + find_package(boost_functional) + find_package(boost_assert) + find_package(boost_range) + find_package(boost_type_traits) + find_package(boost_smart_ptr) + find_package(boost_io) + find_package(boost_config) + + add_library(boost_filesystem + src/operations.cpp + src/portability.cpp + src/codecvt_error_category.cpp + src/utf8_codecvt_facet.cpp + src/windows_file_codecvt.cpp + src/unique_path.cpp + src/path.cpp + src/path_traits.cpp + ) + add_library(boost::filesystem ALIAS boost_filesystem) + set_property(TARGET boost_filesystem PROPERTY EXPORT_NAME filesystem) + + target_link_libraries(boost_filesystem PUBLIC + boost::core + boost::static_assert + boost::iterator + boost::detail + boost::system + boost::functional + boost::assert + boost::range + boost::type_traits + boost::smart_ptr + boost::io + boost::config + ) + +Then to install, and generate package configuration we just use ``cm_deploy``:: + + cm_deploy(TARGETS boost_filesystem NAMESPACE boost::) + +In addition to generating package configuration for cmake, this will also generate the package configuration for ``pkgconfig``. + +----------------- +Integrated builds +----------------- + +As we were setting up cmake for standalone builds, we made sure we didn't do anything to prevent an integrated build, and even provided an alias target to help ease the process. Finally, to integrate the sources into the build is just a matter of calling ``add_subdirectory`` on each project:: + + file(GLOB LIBS libs/*) + foreach(lib ${LIBS}) + add_subdirectory(${lib}) + endforeach() + +We could also use ``add_subdirectory(${lib} EXCLUDE_FROM_ALL)`` so it builds targets that are not necessary. Of course, every project is still calling ``find_package`` to find prebuilt binaries. Since we don't need to search for those libraries because they are integrated into the build we can call ``cm_ignore_package`` to ignore those dependencies:: + + file(GLOB LIBS libs/*) + + foreach(lib ${LIBS}) + cm_ignore_package(${lib}) + endforeach() + + foreach(lib ${LIBS}) + add_subdirectory(${lib}) + endforeach() + +Of course, this assumes we have conveniently named each directory the same as its package name. diff --git a/cmake/modules/doc/src/CMDeploy.rst b/cmake/modules/doc/src/CMDeploy.rst new file mode 100644 index 0000000000..4032bcca53 --- /dev/null +++ b/cmake/modules/doc/src/CMDeploy.rst @@ -0,0 +1,28 @@ +========= +CMDeploy +========= + +---------- +cm_deploy +---------- + +.. program:: cm_deploy + +This will install targets, as well as generate package configuration for both cmake and pkgconfig. + +.. option:: TARGETS ... + +The name of the targets to deploy. + +.. option:: INCLUDE ... + +Include directories to be installed. It also makes the include directory available for targets to be installed. + +.. option:: NAMESPACE + +This is the namespace to add to the targets that are exported. + +.. option:: COMPATIBILITY + +This uses the version compatibility specified by cmake version config. + diff --git a/cmake/modules/doc/src/CMExport.rst b/cmake/modules/doc/src/CMExport.rst new file mode 100644 index 0000000000..6bbca02710 --- /dev/null +++ b/cmake/modules/doc/src/CMExport.rst @@ -0,0 +1,31 @@ +========= +CMExport +========= + +--------------- +cm_auto_export +--------------- + +.. program:: cm_auto_export + +This generates a simple cmake config file that includes the exported targets. + +.. option:: EXPORT + +This specifies an export file. By default, the export file will be named ``${PROJECT_NAME}-targets``. + +.. option:: NAMESPACE + +This is the namespace to add to the targets that are exported. + +.. option:: COMPATIBILITY + +This uses the version compatibility specified by cmake version config. + +.. option:: NAME + +This is the name to use for the package config file. By default, this uses the project name, but this parameter can override it. + +.. option:: TARGETS ... + +These include the targets to be exported. diff --git a/cmake/modules/doc/src/CMIgnorePackage.rst b/cmake/modules/doc/src/CMIgnorePackage.rst new file mode 100644 index 0000000000..03c32a4854 --- /dev/null +++ b/cmake/modules/doc/src/CMIgnorePackage.rst @@ -0,0 +1,15 @@ +========= +CMIgnorePackage +========= + +------------------ +cm_ignore_package +------------------ + +.. program:: cm_ignore_package + +This will ignore a package so that subsequent calls to `find_package` will be treated as found. This is useful in the superproject of integrated builds because it will ingore the ``find_package`` calls to a dependency becaue the targets are already provided by ``add_subdirectory``. + +.. option:: NAME + +The name of the package to ignore. \ No newline at end of file diff --git a/cmake/modules/doc/src/CMInstallTargets.rst b/cmake/modules/doc/src/CMInstallTargets.rst new file mode 100644 index 0000000000..8580b84ba2 --- /dev/null +++ b/cmake/modules/doc/src/CMInstallTargets.rst @@ -0,0 +1,25 @@ +================= +CMInstallTargets +================= + +------------------- +cm_install_targets +------------------- + +.. program:: cm_install_targets + +This installs the targets specified. The directories will be installed according to GNUInstallDirs. +It will also install a corresponding cmake package config(which can be found with ``find_package``) to link against the library targets. + +.. option:: TARGETS ... + +The name of the targets to install. + +.. option:: INCLUDE ... + +Include directories to be installed. It also makes the include directory available for targets to be installed. + +.. option:: EXPORT + +This specifies an export file. By default, the export file will be named ``${PROJECT_NAME}-targets``. + diff --git a/cmake/modules/doc/src/CMPkgConfig.rst b/cmake/modules/doc/src/CMPkgConfig.rst new file mode 100644 index 0000000000..470485968b --- /dev/null +++ b/cmake/modules/doc/src/CMPkgConfig.rst @@ -0,0 +1,59 @@ +============ +CMPkgConfig +============ + +--------------------------- +cm_generate_pkgconfig_file +--------------------------- + +.. program:: cm_generate_pkgconfig_file + +This will generate a simple pkgconfig file. + +.. option:: NAME + +This is the name of the pkgconfig module. + +.. option:: LIB_DIR + +This is the directory where the library is linked to. This defaults to ``${CMAKE_INSTALL_LIBDIR}``. + +.. option:: INCLUDE_DIR + +This is the include directory where the header file are installed. This defaults to ``${CMAKE_INSTALL_INCLUDEDIR}``. + +.. option:: DESCRIPTION + +A description about the library. + +.. option:: TARGETS ... + +The library targets to link. + +.. option:: CFLAGS ... + +Additionaly, compiler flags. + +.. option:: LIBS ... + +Additional libraries to be linked. + +.. option:: REQUIRES ... + +List of other pkgconfig packages that this module depends on. + +------------------ +cm_auto_pkgconfig +------------------ + +.. program:: cm_auto_pkgconfig + +This will auto generate pkgconfig from a given target. All the compiler and linker flags come from the target. + +.. option:: NAME + +This is the name of the pkgconfig module. By default, this will use the project name. + +.. option:: TARGET + +This is the target which will be used to set the various pkgconfig fields. diff --git a/cmake/modules/doc/src/CMProperties.rst b/cmake/modules/doc/src/CMProperties.rst new file mode 100644 index 0000000000..37880d0fce --- /dev/null +++ b/cmake/modules/doc/src/CMProperties.rst @@ -0,0 +1,65 @@ +============= +CMProperties +============= + +This module defines several properties that can be used to control language features in C++. + +-------------- +CXX_EXCEPTIONS +-------------- + +This property can be used to enable or disable C++ exceptions. This can be applied at global, directory or target scope. At global scope this defaults to On. + +-------- +CXX_RTTI +-------- + +This property can be used to enable or disable C++ runtime type information. This can be applied at global, directory or target scope. At global scope this defaults to On. + +------------------ +CXX_STATIC_RUNTIME +------------------ + +This property can be used to enable or disable linking against the static C++ runtime. This can be applied at global, directory or target scope. At global scope this defaults to Off. + +------------ +CXX_WARNINGS +------------ + +The ``CXX_WARNINGS`` property controls the warning level of compilers. It has the following values: + +* ``off`` - disables all warnings. +* ``on`` - enables default warning level for the tool. +* ``all`` - enables all warnings. + +Default value is ``on``. + +---------------------- +CXX_WARNINGS_AS_ERRORS +---------------------- + +The ``CXX_WARNINGS_AS_ERRORS`` property makes it possible to treat warnings as errors and abort compilation on a warning. The value ``on`` enables this behaviour. The default value is ``off``. + +--------------------- +INTERFACE_DESCRIPTION +--------------------- + +Description of the target. + +------------- +INTERFACE_URL +------------- + +An URL where people can get more information about and download the package. + +----------------------------- +INTERFACE_PKG_CONFIG_REQUIRES +----------------------------- + +A list of packages required by this package for pkgconfig. The versions of these packages may be specified using the comparison operators =, <, >, <= or >=. + +------------------------- +INTERFACE_PKG_CONFIG_NAME +------------------------- + +The name of the pkgconfig package for this target. diff --git a/cmake/modules/doc/src/CMSetupVersion.rst b/cmake/modules/doc/src/CMSetupVersion.rst new file mode 100644 index 0000000000..d9f145c777 --- /dev/null +++ b/cmake/modules/doc/src/CMSetupVersion.rst @@ -0,0 +1,33 @@ +=============== +CMSetupVersion +=============== + +----------------- +cm_setup_version +----------------- + +.. program:: cm_setup_version + +This sets up the project version by setting these version variables:: + + PROJECT_VERSION, ${PROJECT_NAME}_VERSION + PROJECT_VERSION_MAJOR, ${PROJECT_NAME}_VERSION_MAJOR + PROJECT_VERSION_MINOR, ${PROJECT_NAME}_VERSION_MINOR + PROJECT_VERSION_PATCH, ${PROJECT_NAME}_VERSION_PATCH + +.. option:: VERSION .. + +This is the version to be set. + +.. option:: GENERATE_HEADER + +This is a header which will be generated with defines for the version number. + +.. option:: PREFIX + +By default, the upper case of the project name is used as a prefix for the version macros that are defined in the generated header: ``${PREFIX}_VERSION_MAJOR``, ``${PREFIX}_VERSION_MINOR``, ``${PREFIX}_VERSION_PATCH``, and ``${PREFIX}_VERSION``. The ``PREFIX`` option allows overriding the prefix name used for the macros. + +.. option:: PARSE_HEADER + +Rather than set a version and generate a header, this will parse a header with macros that define the version, and then use those values to set the version for the project. + diff --git a/cmake/modules/doc/src/CMTest.rst b/cmake/modules/doc/src/CMTest.rst new file mode 100644 index 0000000000..2d75925b69 --- /dev/null +++ b/cmake/modules/doc/src/CMTest.rst @@ -0,0 +1,89 @@ +====== +CMTest +====== + +---------------- +cm_mark_as_test +---------------- + +.. program:: cm_mark_as_test + +This marks the target as a test, so it will be built with the ``tests`` target. If ``BUILD_TESTS`` is set to off then the target will not be built as part of the all target. + +----------------------- +cm_test_link_libraries +----------------------- + +.. program:: cm_test_link_libraries + +This sets libraries that the tests will link against by default. + +-------- +cm_test +-------- + +.. program:: cm_test + +This setups a test. By default, a test will be built and executed. + +.. option:: SOURCES ... + +Source files to be compiled for the test. + +.. option:: CONTENT + +This a string that will be used to create a test to be compiled and/or ran. + +.. option:: NAME + +Name of the test. + +.. option:: ARGS + +This sets additional arguments to be passed to the test executable when it will be ran. + +.. option:: COMPILE_ONLY + +This just compiles the test instead of running it. As such, a ``main`` function is not required. + +.. option:: WILL_FAIL + +Specifies that the test will fail. + +.. option:: NO_TEST_LIBS + +This won't link in the libraries specified by ``cm_test_link_libraries`` + +--------------- +cm_test_header +--------------- + +.. program:: cm_test_header + +This creates a test to test the include of a header. + +.. option:: NAME + +Name of the test. + +.. option:: HEADER + +The header to include. + +.. option:: STATIC + +Rather than just test the include, using ``STATIC`` option will test the include across translation units. This helps check for incorrect include guards and duplicate symbols. + +.. option:: NO_TEST_LIBS + +This won't link in the libraries specified by ``cm_test_link_libraries`` + +------------------------- +cm_add_test_subdirectory +------------------------- + +.. program:: cm_add_test_subdirectory + +This calls ``add_subdirectory`` if the ``ENABLE_TESTS`` property is true. The default value for the property is set by ``CMAKE_ENABLE_TESTS`` variable. + + diff --git a/cmake/modules/doc/src/Intro.rst b/cmake/modules/doc/src/Intro.rst new file mode 100644 index 0000000000..4174dc7a32 --- /dev/null +++ b/cmake/modules/doc/src/Intro.rst @@ -0,0 +1,89 @@ + +========== +Motivation +========== + +This provides cmake modules that can be re-used by boost and other dependencies. It provides modules to reduce the boilerplate for installing, versioning, setting up package config, and creating tests. + +===== +Usage +===== + +The modules can be installed using standard cmake install:: + + mkdir build + cd build + cmake .. + cmake --build . --target install + +Once installed, the modules can be used by using ``find_package`` and then including the appropriate module:: + + find_package(CM) + include(CMDeploy) + +=========== +Quick Start +=========== + +------------------------ +Building a boost library +------------------------ + +The BCM modules provide some high-level cmake functions to take care of all the cmake boilerplate needed to build, install and configuration setup. To setup a simple boost library we can do:: + + cmake_minimum_required (VERSION 3.5) + project(boost_config) + + find_package(CM) + include(CMDeploy) + include(CMSetupVersion) + + cm_setup_version(VERSION 1.58.0) + + add_library(boost_config INTERFACE) + add_library(boost::config ALIAS boost_config) + set_property(TARGET boost_config PROPERTY EXPORT_NAME config) + + cm_deploy(TARGETS config INCLUDE include) + + +This sets up the Boost.Config cmake with the version ``1.64.0``. More importantly the user can now install the library, like this:: + + mkdir build + cd build + cmake .. + cmake --build . --target install + +And then the user can build with Boost.Config using cmake's ``find_package``:: + + project(foo) + + find_package(boost_config) + add_executable(foo foo.cpp) + target_link_libraries(foo boost::config) + +Or if the user isn't using cmake, then ``pkg-config`` can be used instead:: + + g++ `pkg-config boost_config --cflags --libs` foo.cpp + +----- +Tests +----- + +The BCM modules provide functions for creating tests that integrate into cmake's ctest infrastructure. All tests can be built and ran using ``make check``. The ``cm_test`` function can add a test to be ran:: + + cm_test(NAME config_test_c SOURCES config_test_c.c) + +This will compile the ``SOURCES`` and run them. The test also needs to link in ``boost_config``. This can be done with ``target_link_libraries``:: + + target_link_libraries(config_test_c boost::config) + +Or all tests in the directory can be set using ``cm_test_link_libraries``:: + + cm_test_link_libraries(boost::config) + +And all tests in the directory will use ``boost::config``. + +Also, tests can be specified as compile-only or as expected to fail:: + + cm_test(NAME test_thread_fail1 SOURCES threads/test_thread_fail1.cpp COMPILE_ONLY WILL_FAIL) diff --git a/cmake/modules/doc/src/Modules.rst b/cmake/modules/doc/src/Modules.rst new file mode 100644 index 0000000000..1f73b4ccc1 --- /dev/null +++ b/cmake/modules/doc/src/Modules.rst @@ -0,0 +1,15 @@ +Modules +======= + +.. toctree:: + :maxdepth: 3 + + CMDeploy + CMExport + CMIgnorePackage + CMInstallTargets + CMPkgConfig + CMProperties + CMSetupVersion + CMTest + diff --git a/cmake/modules/share/modules/cmake/CMConfig.cmake b/cmake/modules/share/modules/cmake/CMConfig.cmake new file mode 100644 index 0000000000..dfa0cfc38c --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMConfig.cmake @@ -0,0 +1,144 @@ +list(APPEND CMAKE_MODULE_PATH .) +include(CMFuture) +enable_testing() + +function(contains_path FILEPATH SUBPATH RESULT) + file(RELATIVE_PATH PATH "${SUBPATH}" "${FILEPATH}") + if(${PATH} MATCHES "\\.\\./") + set(${RESULT} FALSE PARENT_SCOPE) + else() + set(${RESULT} TRUE PARENT_SCOPE) + endif() +endfunction() + +function(add_subdirectories curdir) + file(GLOB children RELATIVE ${curdir} ${curdir}/*) + set(dirlist "") + foreach(child ${children}) + if(IS_DIRECTORY ${curdir}/${child}) + file(GLOB is_subproject ${curdir}/${child}/*CMakeLists.txt) + if(is_subproject) + add_subdirectory(${curdir}/${child}) + endif() + endif() + endforeach() +endfunction() + +function(cm_project INPUT_PROJECT_NAME) + set(options) + set(oneValueArgs DESCRIPTION VERSION WORKSPACE_NAME) + set(multiValueArgs LANGUAGES) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(PARSE_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to workspace(): \"${PARSE_UNPARSED_ARGUMENTS}\"") + endif() + + if(PARSE_WORKSPACE_NAME) + if(PARSE_VERSION AND PARSE_LANGUAGES AND PARSE_DESCRIPTION) + project(${INPUT_WORKSPACE_NAME}_${INPUT_PROJECT_NAME} + VERSION ${PARSE_VERSION} + DESCRIPTION ${PARSE_DESCRIPTION} + LANGUAGES ${PARSE_LANGUAGES}) + elseif(PARSE_LANGUAGES) + project(${INPUT_WORKSPACE_NAME}_${INPUT_PROJECT_NAME} ${PARSE_LANGUAGES}) + else() + project(${INPUT_WORKSPACE_NAME}_${INPUT_PROJECT_NAME}) + endif() + endif() + + set(CURRENT_PROJECT_NAME ${INPUT_PROJECT_NAME} PARENT_SCOPE) + set(CMAKE_PROJECT_NAME ${CMAKE_PROJECT_NAME} PARENT_SCOPE) + set(PROJECT_NAME ${INPUT_PROJECT_NAME} PARENT_SCOPE) + + string(TOUPPER ${INPUT_PROJECT_NAME} UPPER_PROJECT_NAME) + set(CURRENT_UPPER_PROJECT_NAME ${UPPER_PROJECT_NAME} PARENT_SCOPE) + + if(PARSE_WORKSPACE_NAME) + file(RELATIVE_PATH RELATIVE_DIR ${CMAKE_WORKSPACE_DIR} .) + + set(CURRENT_SOURCES_DIR ${CMAKE_WORKSPACE_SOURCES_DIR}/${RELATIVE_DIR} PARENT_SCOPE) + set(CURRENT_TEST_SOURCES_DIR ${CMAKE_WORKSPACE_SOURCES_DIR}/${RELATIVE_DIR}/test PARENT_SCOPE) + endif() +endfunction() + +function(cm_workspace WORKSPACE_NAME) + set(options) + set(oneValueArgs DESCRIPTION VERSION SOURCES_DIR) + set(multiValueArgs LANGUAGES) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(PARSE_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to workspace(): \"${PARSE_UNPARSED_ARGUMENTS}\"") + endif() + + project(${WORKSPACE_NAME} ${PARSE_VERSION} ${PARSE_DESCRIPTION} ${PARSE_LANGUAGES}) + if (NOT PROJECT_NAME) + set(PROJECT_NAME ${WORKSPACE_NAME} PARENT_SCOPE) + endif() + if (NOT CMAKE_PROJECT_NAME) + set(CMAKE_PROJECT_NAME ${WORKSPACE_NAME} PARENT_SCOPE) + endif() + set(CMAKE_WORKSPACE_NAME ${WORKSPACE_NAME} PARENT_SCOPE) + set(CMAKE_WORKSPACE_LIST ${CMAKE_WORKSPACE_LIST} ${CMAKE_WORKSPACE_NAME} PARENT_SCOPE) + set(CMAKE_WORKSPACE_DIR . PARENT_SCOPE) + string(TOUPPER ${WORKSPACE_NAME} UPPER_WORKSPACE_NAME) + set(CMAKE_UPPER_WORKSPACE_NAME ${UPPER_WORKSPACE_NAME} PARENT_SCOPE) + + if(PARSE_SOURCES_DIR) + set(CMAKE_WORKSPACE_SOURCES_DIR ${PARSE_SOURCES_DIR} PARENT_SCOPE) + endif() +endfunction() + +function(patch_file INPUT_SOURCE INPUT_PATCH OUTPUT_DIRECTORY) + set(options) + set(oneValueArgs PREFIX_PATCH_NAME POSTFIX_PATCH_NAME) + set(multiValueArgs) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + find_package(Patch) + if(NOT Patch_FOUND) + message("Patch utulity is not found") + endif() + string(REPLACE ${CURRENT_TEST_SOURCES_DIR} ${CMAKE_CURRENT_BINARY_DIR} OUTPUT_FILE ${INPUT_SOURCE}) + file(COPY ${INPUT_SOURCE} DESTINATION ${OUTPUT_DIRECTORY}) + get_filename_component(SOURCE_FILE_NAME ${INPUT_SOURCE} NAME) + set(NEW_SOURCE_FILE_NAME ${PARSE_PREFIX_PATCH_NAME}${SOURCE_FILE_NAME}) + if(PARSE_POSTFIX_PATCH_NAME) + string(REPLACE . ${PARSE_POSTFIX_PATCH_NAME}. NEW_SOURCE_FILE_NAME ${NEW_SOURCE_FILE_NAME}) + endif() + file(RENAME ${OUTPUT_DIRECTORY}/${SOURCE_FILE_NAME} ${OUTPUT_DIRECTORY}/${NEW_SOURCE_FILE_NAME}) + execute_process(COMMAND patch ${OUTPUT_DIRECTORY}/${NEW_SOURCE_FILE_NAME} ${INPUT_PATCH} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +endfunction() + +function(patch_directory SOURCES_DIRECTORY PATCHES_DIRECTORY OUTPUT_DIRECTORY) + set(options) + set(oneValueArgs PREFIX_PATCH_NAME POSTFIX_PATCH_NAME) + set(multiValueArgs) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + find_package(Patch) + if(NOT Patch_FOUND) + message("Patch utulity is not found") + endif() + file(GLOB_RECURSE PATCHES_FILES LIST_DIRECTORIES FALSE ${PATCHES_DIRECTORY}/*.patch) + file(GLOB_RECURSE SOURCES_FILES LIST_DIRECTORIES FALSE ${SOURCES_DIRECTORY}/*) + foreach(PATCH_FILE IN LISTS PATCHES_FILES) + string(REPLACE ".patch" "" SOURCE_FILE_NAME ${PATCH_FILE}) + string(REPLACE ${PATCHES_DIRECTORY} ${SOURCES_DIRECTORY} SOURCE_FILE_NAME ${SOURCE_FILE_NAME}) + list(FIND SOURCES_FILES ${SOURCE_FILE_NAME} SOURCES_FILE_FIND) + if(${SOURCES_FILE_FIND} EQUAL -1) + message(FATAL_ERROR "Source file for patch is not found: " ${PATCH_FILE}) + endif() + list(GET SOURCES_FILES ${SOURCES_FILE_FIND} SOURCE_FILE) + string(REPLACE ${SOURCES_DIRECTORY} ${OUTPUT_DIRECTORY} OUTPUT_FILE_DIRECTORY ${SOURCE_FILE}) + get_filename_component(OUTPUT_FILE_DIRECTORY ${OUTPUT_FILE_DIRECTORY} DIRECTORY) + patch_file(${SOURCE_FILE} ${PATCH_FILE} ${OUTPUT_FILE_DIRECTORY} + PREFIX_PATCH_NAME ${PARSE_PREFIX_PATCH_NAME} POSTFIX_PATCH_NAME ${PARSE_POSTFIX_PATCH_NAME}) + endforeach() +endfunction() diff --git a/cmake/modules/share/modules/cmake/CMDeploy.cmake b/cmake/modules/share/modules/cmake/CMDeploy.cmake new file mode 100644 index 0000000000..eb686ab685 --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMDeploy.cmake @@ -0,0 +1,48 @@ + +include(CMPkgConfig) +include(CMInstallTargets) +include(CMExport) + +function(cm_deploy) + set(options SKIP_HEADER_INSTALL) + set(oneValueArgs NAMESPACE COMPATIBILITY PACKAGE_NAME) + set(multiValueArgs TARGETS INCLUDE) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(PARSE_PACKAGE_NAME) + set(PACKAGE_NAME ${PARSE_PACKAGE_NAME}) + else() + set(PACKAGE_NAME ${PROJECT_NAME}) + endif() + + if(PARSE_SKIP_HEADER_INSTALL) + cm_install_targets(TARGETS ${PARSE_TARGETS} INCLUDE ${PARSE_INCLUDE} SKIP_HEADER_INSTALL) + else() + cm_install_targets(TARGETS ${PARSE_TARGETS} INCLUDE ${PARSE_INCLUDE}) + endif() + + cm_auto_pkgconfig(TARGET ${PARSE_TARGETS}) + cm_auto_export(TARGETS ${PARSE_TARGETS} NAMESPACE ${PARSE_NAMESPACE} COMPATIBILITY ${PARSE_COMPATIBILITY}) + + foreach(TARGET ${PARSE_TARGETS}) + get_target_property(TARGET_NAME ${TARGET} EXPORT_NAME) + if(NOT TARGET_NAME) + get_target_property(TARGET_NAME ${TARGET} NAME) + endif() + set(EXPORT_LIB_TARGET ${PARSE_NAMESPACE}${TARGET_NAME}) + if(NOT TARGET ${EXPORT_LIB_TARGET}) + add_library(${EXPORT_LIB_TARGET} ALIAS ${TARGET}) + endif() + set_target_properties(${TARGET} PROPERTIES INTERFACE_FIND_PACKAGE_NAME ${PARSE_NAMESPACE}${PACKAGE_NAME}) + if(COMMAND cm_add_rpath) + get_target_property(TARGET_TYPE ${TARGET} TYPE) + if(NOT "${TARGET_TYPE}" STREQUAL "INTERFACE_LIBRARY") + cm_add_rpath("$") + endif() + endif() + cm_shadow_notify(${EXPORT_LIB_TARGET}) + cm_shadow_notify(${TARGET}) + endforeach() + +endfunction() diff --git a/cmake/modules/share/modules/cmake/CMExport.cmake b/cmake/modules/share/modules/cmake/CMExport.cmake new file mode 100644 index 0000000000..552067f148 --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMExport.cmake @@ -0,0 +1,147 @@ +include(GNUInstallDirs) +include(WriteBasicConfigVersionFile) + +function(cm_get_target_package_source OUT_VAR TARGET) + set(RESULT) + if(TARGET ${TARGET}) + get_property(TARGET_ALIAS TARGET ${TARGET} PROPERTY ALIASED_TARGET) + if(TARGET_ALIAS) + set(TARGET ${TARGET_ALIAS}) + endif() + get_property(TARGET_IMPORTED TARGET ${TARGET} PROPERTY IMPORTED) + if(TARGET_IMPORTED OR TARGET_ALIAS) + get_property(TARGET_FIND_PACKAGE_NAME TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_NAME) + if(NOT TARGET_FIND_PACKAGE_NAME) + message(SEND_ERROR "The target ${TARGET_FIND_PACKAGE_NAME} does not have information about find_package() call.") + endif() + set(PKG_NAME ${TARGET_FIND_PACKAGE_NAME}) + get_property(TARGET_FIND_PACKAGE_VERSION TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_VERSION) + if(TARGET_FIND_PACKAGE_VERSION) + set(PKG_NAME "${PKG_NAME} ${TARGET_FIND_PACKAGE_VERSION}") + endif() + get_property(TARGET_FIND_PACKAGE_EXACT TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_EXACT) + if(TARGET_FIND_PACKAGE_EXACT) + set(PKG_NAME "${PKG_NAME} ${TARGET_FIND_PACKAGE_EXACT}") + endif() + set(RESULT "${PKG_NAME}") + # get_property(TARGET_FIND_PACKAGE_REQUIRED TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_REQUIRED) + # get_property(TARGET_FIND_PACKAGE_QUIETLY TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_QUIETLY) + endif() + else() + if("${TARGET}" MATCHES "::") + set(TARGET_NAME "$") + else() + set(TARGET_NAME "${TARGET}") + endif() + cm_shadow_exists(HAS_TARGET ${TARGET}) + set(RESULT "$<${HAS_TARGET}:$>") + endif() + set(${OUT_VAR} "${RESULT}" PARENT_SCOPE) +endfunction() + +function(cm_auto_export) + set(options) + set(oneValueArgs NAMESPACE EXPORT NAME COMPATIBILITY) + set(multiValueArgs TARGETS) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) + string(TOLOWER ${CMAKE_WORKSPACE_NAME} CMAKE_WORKSPACE_NAME_LOWER) + set(PACKAGE_NAME ${PROJECT_NAME}) + if(PARSE_NAME) + set(PACKAGE_NAME ${PARSE_NAME}) + endif() + + string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER) + string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) + + set(TARGET_FILE ${CMAKE_WORKSPACE_NAME_LOWER}-${PROJECT_NAME_LOWER}-targets) + if(PARSE_EXPORT) + set(TARGET_FILE ${PARSE_EXPORT}) + endif() + set(CONFIG_NAME ${PACKAGE_NAME_LOWER}-config) + set(TARGET_VERSION ${PROJECT_VERSION}) + + set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) + set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) + set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) + set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/${PACKAGE_NAME_LOWER}) + + set(CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}.cmake") + + set(CONFIG_FILE_CONTENT " +include(CMakeFindDependencyMacro) +") + + if(PARSE_TARGETS) + # Add dependencies + foreach(TARGET ${PARSE_TARGETS}) + get_property(TARGET_LIBS TARGET ${TARGET} PROPERTY INTERFACE_LINK_LIBRARIES) + foreach(LIB ${TARGET_LIBS}) + cm_get_target_package_source(PKG_SRC ${LIB}) + set(HAS_PKG_SRC "$") + string(APPEND CONFIG_FILE_CONTENT "# $<$:Skip >Library: ${LIB}\n") + string(APPEND CONFIG_FILE_CONTENT "$<${HAS_PKG_SRC}:find_dependency(${PKG_SRC})>\n") + endforeach() + endforeach() + # Compute targets imported name + set(EXPORT_LIB_TARGETS) + foreach(TARGET ${PARSE_TARGETS}) + get_target_property(TARGET_NAME ${TARGET} EXPORT_NAME) + if(NOT TARGET_NAME) + get_target_property(TARGET_NAME ${TARGET} NAME) + endif() + set(EXPORT_LIB_TARGET_${TARGET} ${PARSE_NAMESPACE}${TARGET_NAME}) + list(APPEND EXPORT_LIB_TARGETS ${EXPORT_LIB_TARGET_${TARGET}}) + endforeach() + # Export custom properties + set(EXPORT_PROPERTIES) + foreach(TARGET ${PARSE_TARGETS}) + # TODO: Make this a property: the custom properties to be exported + foreach(PROPERTY INTERFACE_PKG_CONFIG_NAME) + set(PROP "$") + set(EXPORT_PROPERTIES "${EXPORT_PROPERTIES} +$<$:set_target_properties(${EXPORT_LIB_TARGET_${TARGET}} PROPERTIES ${PROPERTY} ${PROP})> +") + endforeach() + endforeach() + string(APPEND CONFIG_FILE_CONTENT " +include(\"\${CMAKE_CURRENT_LIST_DIR}/${TARGET_FILE}.cmake\") +include(\"\${CMAKE_CURRENT_LIST_DIR}/properties-${TARGET_FILE}.cmake\") +") + endif() + + file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/properties-${TARGET_FILE}.cmake CONTENT "${EXPORT_PROPERTIES}") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/properties-${TARGET_FILE}.cmake DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR}) + + file(GENERATE OUTPUT "${CONFIG_FILE}" CONTENT "${CONFIG_FILE_CONTENT}") + + set(COMPATIBILITY_ARG SameMajorVersion) + if(PARSE_COMPATIBILITY) + set(COMPATIBILITY_ARG ${PARSE_COMPATIBILITY}) + endif() + write_basic_config_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}-version.cmake + VERSION ${TARGET_VERSION} + COMPATIBILITY ${COMPATIBILITY_ARG} + ) + + set(NAMESPACE_ARG) + if(PARSE_NAMESPACE) + set(NAMESPACE_ARG "NAMESPACE;${PARSE_NAMESPACE}") + endif() + install(EXPORT ${TARGET_FILE} + DESTINATION + ${CONFIG_PACKAGE_INSTALL_DIR} + ${NAMESPACE_ARG} + ) + + install(FILES + ${CONFIG_FILE} + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}-version.cmake + DESTINATION + ${CONFIG_PACKAGE_INSTALL_DIR}) + +endfunction() + diff --git a/cmake/modules/share/modules/cmake/CMFuture.cmake b/cmake/modules/share/modules/cmake/CMFuture.cmake new file mode 100644 index 0000000000..68a21c7288 --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMFuture.cmake @@ -0,0 +1,87 @@ +define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_NAME" + BRIEF_DOCS "The package name that was searched for to create this target" + FULL_DOCS "The package name that was searched for to create this target" +) + +define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_REQUIRED" + BRIEF_DOCS "true if REQUIRED option was given" + FULL_DOCS "true if REQUIRED option was given" +) + +define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_QUIETLY" + BRIEF_DOCS "true if QUIET option was given" + FULL_DOCS "true if QUIET option was given" +) + +define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_EXACT" + BRIEF_DOCS "true if EXACT option was given" + FULL_DOCS "true if EXACT option was given" +) + +define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_VERSION" + BRIEF_DOCS "full requested version string" + FULL_DOCS "full requested version string" +) + +# Custom property to check if target exists +define_property(TARGET PROPERTY "INTERFACE_TARGET_EXISTS" + BRIEF_DOCS "True if target exists" + FULL_DOCS "True if target exists" +) +# Create shadow target to notify that the target exists +macro(cm_shadow_notify TARGET) + if(NOT TARGET _cm_shadow_target_${TARGET}) + add_library(_cm_shadow_target_${TARGET} INTERFACE IMPORTED GLOBAL) + endif() + set_target_properties(_cm_shadow_target_${TARGET} PROPERTIES INTERFACE_TARGET_EXISTS 1) +endmacro() +# Check if target exists by querying the shadow target +macro(cm_shadow_exists OUT TARGET) + if("${TARGET}" MATCHES "^[_a-zA-Z0-9:]+$") + if(NOT TARGET _cm_shadow_target_${TARGET}) + add_library(_cm_shadow_target_${TARGET} INTERFACE IMPORTED GLOBAL) + set_target_properties(_cm_shadow_target_${TARGET} PROPERTIES INTERFACE_TARGET_EXISTS 0) + endif() + set(${OUT} "$") + else() + set(${OUT} "0") + endif() +endmacro() +# Emulate rpath for windows +if(WIN32) + if(NOT COMMAND cm_add_rpath) + foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES} "") + file(WRITE ${CMAKE_BINARY_DIR}/cm_set_rpath_pre-${CONFIG}.cmake "set(RPATH)\n") + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/cm_set_rpath-${CONFIG}.cmake INPUT ${CMAKE_BINARY_DIR}/cm_set_rpath_pre-${CONFIG}.cmake CONDITION $) + endforeach() + function(cm_add_rpath) + foreach(_RPATH ${ARGN}) + foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES} "") + file(APPEND ${CMAKE_BINARY_DIR}/cm_set_rpath_pre-${CONFIG}.cmake "list(APPEND RPATH \"${_RPATH}\")\n") + endforeach() + endforeach() + endfunction() + endif() +endif() +# Add library extension to track imported targets +if(NOT COMMAND cm_add_library_ext) + macro(cm_add_library_ext LIB) + set(ARG_LIST "${ARGN}") + if("IMPORTED" IN_LIST ARG_LIST) + if(CMAKE_FIND_PACKAGE_NAME) + set_target_properties(${LIB} PROPERTIES INTERFACE_FIND_PACKAGE_NAME ${CMAKE_FIND_PACKAGE_NAME}) + foreach(TYPE REQUIRED QUIETLY EXACT VERSION) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_${TYPE}) + set_target_properties(${LIB} PROPERTIES INTERFACE_FIND_PACKAGE_${TYPE} ${${CMAKE_FIND_PACKAGE_NAME}_FIND_${TYPE}}) + endif() + endforeach() + endif() + endif() + endmacro() + + macro(add_library) + _add_library(${ARGN}) + cm_add_library_ext(${ARGN}) + endmacro() + +endif() diff --git a/cmake/modules/share/modules/cmake/CMIgnorePackage.cmake b/cmake/modules/share/modules/cmake/CMIgnorePackage.cmake new file mode 100644 index 0000000000..677652d72d --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMIgnorePackage.cmake @@ -0,0 +1,6 @@ + +function(cm_ignore_package NAME) + set(${NAME}_DIR ${CMAKE_BINARY_DIR}/_cm_ignore_packages_/${NAME} CACHE PATH "") + file(WRITE ${${NAME}_DIR}/${NAME}Config.cmake "") +endfunction() + diff --git a/cmake/modules/share/modules/cmake/CMInstallTargets.cmake b/cmake/modules/share/modules/cmake/CMInstallTargets.cmake new file mode 100644 index 0000000000..69dbdd7aaa --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMInstallTargets.cmake @@ -0,0 +1,43 @@ +include(GNUInstallDirs) + +function(cm_install_targets) + set(options SKIP_HEADER_INSTALL) + set(oneValueArgs EXPORT) + set(multiValueArgs TARGETS INCLUDE) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) + string(TOLOWER ${CMAKE_WORKSPACE_NAME} CMAKE_WORKSPACE_NAME_LOWER) + set(EXPORT_FILE ${CMAKE_WORKSPACE_NAME_LOWER}-${PROJECT_NAME_LOWER}-targets) + if(PARSE_EXPORT) + set(EXPORT_FILE ${PARSE_EXPORT}) + endif() + + set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) + set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) + set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) + + foreach(TARGET ${PARSE_TARGETS}) + foreach(INCLUDE ${PARSE_INCLUDE}) + get_filename_component(INCLUDE_PATH ${INCLUDE} ABSOLUTE) + target_include_directories(${TARGET} INTERFACE $) + endforeach() + target_include_directories(${TARGET} INTERFACE $/${INCLUDE_INSTALL_DIR}>) + endforeach() + + + if(NOT PARSE_SKIP_HEADER_INSTALL) + foreach(INCLUDE ${PARSE_INCLUDE}) + install(DIRECTORY ${INCLUDE}/ DESTINATION ${INCLUDE_INSTALL_DIR}) + endforeach() + endif() + + install(TARGETS ${PARSE_TARGETS} + EXPORT ${EXPORT_FILE} + RUNTIME DESTINATION ${BIN_INSTALL_DIR} + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) + +endfunction() + diff --git a/cmake/modules/share/modules/cmake/CMPkgConfig.cmake b/cmake/modules/share/modules/cmake/CMPkgConfig.cmake new file mode 100644 index 0000000000..4e447e8d29 --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMPkgConfig.cmake @@ -0,0 +1,250 @@ + +include(GNUInstallDirs) + +define_property(TARGET PROPERTY "INTERFACE_DESCRIPTION" + BRIEF_DOCS "Description of the target" + FULL_DOCS "Description of the target" +) + +define_property(TARGET PROPERTY "INTERFACE_URL" + BRIEF_DOCS "An URL where people can get more information about and download the package." + FULL_DOCS "An URL where people can get more information about and download the package." +) + +define_property(TARGET PROPERTY "INTERFACE_PKG_CONFIG_REQUIRES" + BRIEF_DOCS "A list of packages required by this package. The versions of these packages may be specified using the comparison operators =, <, >, <= or >=." + FULL_DOCS "A list of packages required by this package. The versions of these packages may be specified using the comparison operators =, <, >, <= or >=." +) + +function(cm_generate_pkgconfig_file) + set(options) + set(oneValueArgs NAME LIB_DIR INCLUDE_DIR DESCRIPTION) + set(multiValueArgs TARGETS CFLAGS LIBS REQUIRES) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(LIB_DIR ${CMAKE_INSTALL_LIBDIR}) + if(PARSE_LIB_DIR) + set(LIB_DIR ${PARSE_LIB_DIR}) + endif() + set(INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}) + if(PARSE_INCLUDE_DIR) + set(INCLUDE_DIR ${PARSE_INCLUDE_DIR}) + endif() + + set(LIBS) + set(DESCRIPTION "No description") + if(PARSE_DESCRIPTION) + set(DESCRIPTION ${PARSE_DESCRIPTION}) + endif() + + foreach(TARGET ${PARSE_TARGETS}) + get_property(TARGET_NAME TARGET ${TARGET} PROPERTY NAME) + get_property(TARGET_TYPE TARGET ${TARGET} PROPERTY TYPE) + if(NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY") + set(LIBS "${LIBS} -l${TARGET_NAME}") + endif() + endforeach() + + if(LIBS OR PARSE_LIBS) + set(LIBS "Libs: -L\${libdir} ${LIBS} ${PARSE_LIBS}") + endif() + + set(PKG_NAME ${PROJECT_NAME}) + if(PARSE_NAME) + set(PKG_NAME ${PARSE_NAME}) + endif() + + file(WRITE ${PKGCONFIG_FILENAME} +" +prefix=${CMAKE_INSTALL_PREFIX} +exec_prefix=\${prefix} +libdir=\${exec_prefix}/${LIB_DIR} +includedir=\${exec_prefix}/${INCLUDE_DIR} +Name: ${PKG_NAME} +Description: ${DESCRIPTION} +Version: ${PROJECT_VERSION} +Cflags: -I\${includedir} ${PARSE_CFLAGS} +${LIBS} +Requires: ${PARSE_REQUIRES} +" + ) + +endfunction() + +function(cm_preprocess_pkgconfig_property VAR TARGET PROP) + get_target_property(OUT_PROP ${TARGET} ${PROP}) + string(REPLACE "$/${CMAKE_INSTALL_INCLUDEDIR}" "\${includedir}" OUT_PROP "${OUT_PROP}") + string(REPLACE "$/${CMAKE_INSTALL_LIBDIR}" "\${libdir}" OUT_PROP "${OUT_PROP}") + string(REPLACE "$" "\${prefix}" OUT_PROP "${OUT_PROP}") + + set(${VAR} ${OUT_PROP} PARENT_SCOPE) + +endfunction() + +function(cm_auto_pkgconfig_each) + set(options) + set(oneValueArgs NAME TARGET) + set(multiValueArgs) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(LIBS) + set(CFLAGS) + set(REQUIRES) + set(DESCRIPTION "No description") + + string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) + set(PACKAGE_NAME ${PROJECT_NAME}) + + set(TARGET) + if(PARSE_TARGET) + set(TARGET ${PARSE_TARGET}) + else() + message(SEND_ERROR "Target is required for auto pkg config") + endif() + + if(PARSE_NAME) + set(PACKAGE_NAME ${PARSE_NAME}) + endif() + + string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER) + string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) + + get_property(TARGET_NAME TARGET ${TARGET} PROPERTY NAME) + get_property(TARGET_TYPE TARGET ${TARGET} PROPERTY TYPE) + get_property(TARGET_DESCRIPTION TARGET ${TARGET} PROPERTY INTERFACE_DESCRIPTION) + get_property(TARGET_URL TARGET ${TARGET} PROPERTY INTERFACE_URL) + get_property(TARGET_REQUIRES TARGET ${TARGET} PROPERTY INTERFACE_PKG_CONFIG_REQUIRES) + if(NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY") + set(LIBS "${LIBS} -l${TARGET_NAME}") + endif() + + if(TARGET_REQUIRES) + list(APPEND REQUIRES ${TARGET_REQUIRES}) + endif() + + cm_preprocess_pkgconfig_property(LINK_LIBS ${TARGET} INTERFACE_LINK_LIBRARIES) + foreach(LIB ${LINK_LIBS}) + if(TARGET ${LIB}) + get_property(LIB_PKGCONFIG_NAME TARGET ${LIB} PROPERTY INTERFACE_PKG_CONFIG_NAME) + # TODO: Error if this property is missing + if(LIB_PKGCONFIG_NAME) + list(APPEND REQUIRES ${LIB_PKGCONFIG_NAME}) + endif() + else() + if("${LIB}" MATCHES "::") + set(LIB_TARGET_NAME "$") + else() + set(LIB_TARGET_NAME "${LIB}") + endif() + cm_shadow_exists(HAS_LIB_TARGET ${LIB}) + list(APPEND REQUIRES "$<${HAS_LIB_TARGET}:$>") + set(LIBS "${LIBS} $<$:${LIB}>") + endif() + endforeach() + + cm_preprocess_pkgconfig_property(INCLUDE_DIRS ${TARGET} INTERFACE_INCLUDE_DIRECTORIES) + if(INCLUDE_DIRS) + set(CFLAGS "${CFLAGS} $<$:-I$>") + endif() + + cm_preprocess_pkgconfig_property(COMPILE_DEFS ${TARGET} INTERFACE_COMPILE_DEFINITIONS) + if(COMPILE_DEFS) + set(CFLAGS "${CFLAGS} $<$:-D$>") + endif() + + cm_preprocess_pkgconfig_property(COMPILE_OPTS ${TARGET} INTERFACE_COMPILE_OPTIONS) + if(COMPILE_OPTS) + set(CFLAGS "${CFLAGS} $<$:$>") + endif() + + set(CONTENT) + + if(TARGET_DESCRIPTION) + set(DESCRIPTION "${TARGET_DESCRIPTION}") + endif() + + if(TARGET_URL) + set(CONTENT "${CONTENT}\nUrl: ${TARGET_URL}") + endif() + + if(CFLAGS) + set(CONTENT "${CONTENT}\nCflags: ${CFLAGS}") + endif() + + if(LIBS) + set(CONTENT "${CONTENT}\n$<$:Libs: -L\${libdir} ${LIBS}>") + endif() + + if(REQUIRES) + string(REPLACE ";" "," REQUIRES_CONTENT "${REQUIRES}") + set(CONTENT "${CONTENT}\nRequires: ${REQUIRES_CONTENT}") + endif() + + file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_LOWER}.pc CONTENT +" +prefix=${CMAKE_INSTALL_PREFIX} +exec_prefix=\${prefix} +libdir=\${exec_prefix}/${CMAKE_INSTALL_LIBDIR} +includedir=\${exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR} +Name: ${PACKAGE_NAME_LOWER} +Description: ${DESCRIPTION} +Version: ${PROJECT_VERSION} +${CONTENT} +" + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_LOWER}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + set_property(TARGET ${TARGET} PROPERTY INTERFACE_PKG_CONFIG_NAME ${PACKAGE_NAME_LOWER}) +endfunction() + +function(cm_auto_pkgconfig) + set(options) + set(oneValueArgs NAME) + set(multiValueArgs TARGET) # TODO: Rename to TARGETS + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + list(LENGTH PARSE_TARGET TARGET_COUNT) + + if(TARGET_COUNT EQUAL 1) + cm_auto_pkgconfig_each(TARGET ${PARSE_TARGET} NAME ${PARSE_NAME}) + else() + string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) + set(PACKAGE_NAME ${PROJECT_NAME}) + + if(PARSE_NAME) + set(PACKAGE_NAME ${PARSE_NAME}) + endif() + + string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) + + set(GENERATE_PROJECT_PC On) + foreach(TARGET ${PARSE_TARGET}) + if("${TARGET}" STREQUAL "${PACKAGE_NAME_LOWER}") + set(GENERATE_PROJECT_PC Off) + endif() + cm_auto_pkgconfig_each(TARGET ${TARGET} NAME ${TARGET}) + endforeach() + + string(REPLACE ";" "," REQUIRES "${PARSE_TARGET}") + # TODO: Get description from project + set(DESCRIPTION "No description") + + if(GENERATE_PROJECT_PC) + file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_LOWER}.pc CONTENT +" +Name: ${PACKAGE_NAME_LOWER} +Description: ${DESCRIPTION} +Version: ${PROJECT_VERSION} +Requires: ${REQUIRES} +" + ) + endif() + endif() + + +endfunction() diff --git a/cmake/modules/share/modules/cmake/CMProperties.cmake b/cmake/modules/share/modules/cmake/CMProperties.cmake new file mode 100644 index 0000000000..c1adea0b99 --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMProperties.cmake @@ -0,0 +1,98 @@ +# Custom properties from Niall Douglas + +# On MSVC very annoyingly cmake puts /EHsc and /MD(d) into the global flags which means you +# get a warning when you try to disable exceptions or use the static CRT. I hate to use this +# globally imposed solution, but we are going to hack the global flags to use properties to +# determine whether they are on or off +# +# Create custom properties called CXX_EXCEPTIONS, CXX_RTTI and CXX_STATIC_RUNTIME +# These get placed at global, directory and target scopes +foreach(scope GLOBAL DIRECTORY TARGET) + define_property(${scope} PROPERTY "CXX_EXCEPTIONS" INHERITED + BRIEF_DOCS "Enable C++ exceptions, defaults to TRUE at global scope" + FULL_DOCS "Enable C++ exceptions, defaults to TRUE at global scope" + ) + define_property(${scope} PROPERTY "CXX_RTTI" INHERITED + BRIEF_DOCS "Enable C++ runtime type information, defaults to TRUE at global scope" + FULL_DOCS "Enable C++ runtime type information, defaults to TRUE at global scope" + ) + define_property(${scope} PROPERTY "CXX_STATIC_RUNTIME" INHERITED + BRIEF_DOCS "Enable linking against the static C++ runtime, defaults to FALSE at global scope" + FULL_DOCS "Enable linking against the static C++ runtime, defaults to FALSE at global scope" + ) + define_property(${scope} PROPERTY "CXX_WARNINGS" INHERITED + BRIEF_DOCS "Controls the warning level of compilers, defaults to TRUE at global scope" + FULL_DOCS "Controls the warning level of compilers, defaults to TRUE at global scope" + ) + define_property(${scope} PROPERTY "CXX_WARNINGS_AS_ERRORS" INHERITED + BRIEF_DOCS "Treat warnings as errors and abort compilation on a warning, defaults to FALSE at global scope" + FULL_DOCS "Treat warnings as errors and abort compilation on a warning, defaults to FALSE at global scope" + ) + define_property(${scope} PROPERTY "BUILD_SHARED_LIBS" INHERITED + BRIEF_DOCS "Property indicates wether dynamic-linked libraries are going to be built, defaults to + FALSE at global scope" + FULL_DOCS "Property indicates wether dynamic-linked libraries are going to be built, defaults to + FALSE at global scope" + ) +endforeach() +# Set the default for these properties at global scope. If they are not set per target or +# whatever, the next highest scope will be looked up +option(CMAKE_CXX_EXCEPTIONS "Enable C++ exceptions, defaults to TRUE at global scope" TRUE) +option(CMAKE_CXX_RTTI "Enable C++ runtime type information, defaults to TRUE at global scope" TRUE) +option(CMAKE_CXX_STATIC_RUNTIME "Enable linking against the static C++ runtime, defaults to FALSE at global scope" FALSE) +option(CMAKE_CXX_WARNINGS "Controls the warning level of compilers, defaults to TRUE at global scope" TRUE) +option(CMAKE_CXX_WARNINGS_AS_ERRORS "Treat warnings as errors and abort compilation on a warning, defaults to FALSE at global scope" FALSE) + +set_property(GLOBAL PROPERTY CXX_EXCEPTIONS ${CMAKE_CXX_EXCEPTIONS}) +set_property(GLOBAL PROPERTY CXX_RTTI ${CMAKE_CXX_RTTI}) +set_property(GLOBAL PROPERTY CXX_STATIC_RUNTIME ${CMAKE_CXX_STATIC_RUNTIME}) +set_property(GLOBAL PROPERTY CXX_WARNINGS ${CMAKE_CXX_WARNINGS}) +set_property(GLOBAL PROPERTY CXX_WARNINGS_AS_ERRORS ${CMAKE_CXX_WARNINGS_AS_ERRORS}) +set_property(GLOBAL PROPERTY BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) + +if(MSVC) + # Purge unconditional use of /MDd, /MD and /EHsc. + foreach(flag + CMAKE_C_FLAGS CMAKE_CXX_FLAGS + CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG + CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO + ) + string(REPLACE "/MDd" "" ${flag} "${${flag}}") + string(REPLACE "/MD" "" ${flag} "${${flag}}") + string(REPLACE "/EHsc" "" ${flag} "${${flag}}") + string(REPLACE "/GR" "" ${flag} "${${flag}}") + endforeach() + # Restore those same, but now selected by the properties + add_compile_options( + $<$>,TRUE>:/EHsc> + $<$>,FALSE>:/GR-> + $<$>,FALSE>:$<$:/MDd>$<$>:/MD>> + $<$>,TRUE>:$<$:/MTd>$<$>:/MT>> + $<$>,TRUE>:/W3> + $<$>,FALSE>:/W0> + $<$>,ALL>:/W4> + $<$>,TRUE>:/WX> + ) +else() + add_compile_options( + $<$>,FALSE>:-fno-exceptions> + $<$>,FALSE>:-fno-rtti> + $<$>,TRUE>:-static> + $<$>,TRUE>:-Wall> + $<$>,FALSE>:-w> + $<$>,ALL>:-Wall> + $<$>,ALL>:-pedantic> + $<$>,TRUE>:-Werror> + ) + if(CMAKE_${COMPILER}_COMPILER_ID MATCHES "Clang" OR CMAKE_${COMPILER}_COMPILER_ID MATCHES "AppleClang") + add_compile_options( + $<$>,ALL>:-Weverything> + $<$>,ALL>:-Wno-macro-redefined> + $<$>,ALL>:-Wall> + $<$>,ALL>:-Wno-c++98-compat> + $<$>,ALL>:-Wno-c++98-compat-pedantic> + ) + endif() +endif() \ No newline at end of file diff --git a/cmake/modules/share/modules/cmake/CMSetupVersion.cmake b/cmake/modules/share/modules/cmake/CMSetupVersion.cmake new file mode 100644 index 0000000000..b4fe4fb7b6 --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMSetupVersion.cmake @@ -0,0 +1,52 @@ +include(GNUInstallDirs) +set(CM_HEADER_VERSION_TEMPLATE_FILE "version.hpp") + +macro(cm_set_parent VAR) + set(${VAR} ${ARGN} PARENT_SCOPE) + set(${VAR} ${ARGN}) +endmacro() + +function(cm_setup_version) + set(options) + set(oneValueArgs VERSION GENERATE_HEADER PARSE_HEADER PREFIX) + set(multiValueArgs) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + string(TOUPPER ${PROJECT_NAME} PREFIX) + + if(PARSE_PREFIX) + set(PREFIX ${PARSE_PREFIX}) + endif() + + if(PARSE_VERSION) + cm_set_parent(PROJECT_VERSION ${PARSE_VERSION}) + cm_set_parent(${PROJECT_NAME}_VERSION ${PROJECT_VERSION}) + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _version_MAJOR "${PROJECT_VERSION}") + string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _version_MINOR "${PROJECT_VERSION}") + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _version_PATCH "${PROJECT_VERSION}") + foreach(level MAJOR MINOR PATCH) + cm_set_parent(${PROJECT_NAME}_VERSION_${level} ${_version_${level}}) + cm_set_parent(PROJECT_VERSION_${level} ${_version_${level}}) + endforeach() + elseif(PARSE_PARSE_HEADER) + foreach(level MAJOR MINOR PATCH) + file(STRINGS ${PARSE_PARSE_HEADER} + _define_${level} + REGEX "#define ${PREFIX}_VERSION_${level}") + string(REGEX MATCH "([0-9]+)" _version_${level} "${_define_${level}}") + # TODO: Check if it is empty + cm_set_parent(${PROJECT_NAME}_VERSION_${level} ${_version_${level}}) + cm_set_parent(PROJECT_VERSION_${level} ${_version_${level}}) + endforeach() + cm_set_parent(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") + cm_set_parent(${PROJECT_NAME}_VERSION ${PROJECT_VERSION}) + endif() + # TODO: Get version from the project + + if(PARSE_GENERATE_HEADER) + configure_file("${CM_HEADER_VERSION_TEMPLATE_FILE}" "${PARSE_GENERATE_HEADER}") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PARSE_GENERATE_HEADER}" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + endif() + +endfunction() diff --git a/cmake/modules/share/modules/cmake/CMTest.cmake b/cmake/modules/share/modules/cmake/CMTest.cmake new file mode 100644 index 0000000000..5f8a0e2d04 --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMTest.cmake @@ -0,0 +1,232 @@ +option(BUILD_TESTS "Controls whether to build the tests as part of the main build" FALSE) + +enable_testing() + +foreach (scope GLOBAL DIRECTORY) + define_property(${scope} PROPERTY "ENABLE_TESTS" INHERITED + BRIEF_DOCS "Enable tests" + FULL_DOCS "Enable tests" + ) +endforeach () +option(CMAKE_ENABLE_TESTS "Enable tests" ON) +set_property(GLOBAL PROPERTY ENABLE_TESTS ${CMAKE_ENABLE_TESTS}) + +include(ProcessorCount) +processorcount(_cm_ctest_parallel_level) +set(CTEST_PARALLEL_LEVEL ${_cm_ctest_parallel_level} CACHE STRING "CTest parallel level") + +if (NOT TARGET check) + add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR} -j ${CTEST_PARALLEL_LEVEL} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +endif () + + +if (NOT TARGET tests) + add_custom_target(tests COMMENT "Build all tests.") + add_dependencies(check tests) +endif () + +if (NOT TARGET check-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) + add_custom_target(check-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} COMMAND ${CMAKE_CTEST_COMMAND} -L ${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} --output-on-failure -C ${CMAKE_CFG_INTDIR} -j ${CTEST_PARALLEL_LEVEL} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +endif () + +if (NOT TARGET tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) + add_custom_target(tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} COMMENT "Build all tests for ${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}.") + add_dependencies(check-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) +endif () + +function(cm_mark_as_test) + foreach (TEST_TARGET ${ARGN}) + if (NOT BUILD_TESTS) + get_target_property(TEST_TARGET_TYPE ${TEST_TARGET} TYPE) + # We can only use EXCLUDE_FROM_ALL on build targets + if (NOT "${TEST_TARGET_TYPE}" STREQUAL "INTERFACE_LIBRARY") + set_target_properties(${TEST_TARGET} + PROPERTIES EXCLUDE_FROM_ALL TRUE + ) + endif () + endif () + add_dependencies(tests ${TEST_TARGET}) + add_dependencies(tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} ${TEST_TARGET}) + endforeach () +endfunction(cm_mark_as_test) + + +function(cm_create_internal_targets) + if (NOT TARGET _cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}.cpp "") + add_library(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} STATIC ${CMAKE_CURRENT_BINARY_DIR}/_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}.cpp) + cm_mark_as_test(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) + endif () +endfunction() + +foreach (scope DIRECTORY TARGET) + define_property(${scope} PROPERTY "CM_TEST_DEPENDENCIES" INHERITED + BRIEF_DOCS "Default test dependencies" + FULL_DOCS "Default test dependencies" + ) +endforeach () + +function(cm_test_link_libraries) + cm_create_internal_targets() + if (BUILD_TESTS) + set_property(DIRECTORY APPEND PROPERTY CM_TEST_DEPENDENCIES ${ARGN}) + target_link_libraries(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} ${ARGN}) + else () + foreach (TARGET ${ARGN}) + if (TARGET ${TARGET}) + set_property(DIRECTORY APPEND PROPERTY CM_TEST_DEPENDENCIES ${TARGET}) + target_link_libraries(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} ${TARGET}) + elseif (${TARGET} MATCHES "::") + cm_shadow_exists(HAS_TARGET ${TARGET}) + set_property(DIRECTORY APPEND PROPERTY CM_TEST_DEPENDENCIES $<${HAS_TARGET}:${TARGET}>) + target_link_libraries(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} $<${HAS_TARGET}:${TARGET}>) + else () + set_property(DIRECTORY APPEND PROPERTY CM_TEST_DEPENDENCIES ${TARGET}) + target_link_libraries(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} ${TARGET}) + endif () + if (BUILD_SHARED_LIBS) + target_compile_definitions(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} PRIVATE -DBOOST_TEST_DYN_LINK=1 -DBOOST_TEST_NO_AUTO_LINK=1) + endif () + endforeach () + endif () +endfunction() + +function(cm_target_link_test_libs TARGET) + # target_link_libraries(${TARGET} + # $ + # ) + get_property(DEPS DIRECTORY PROPERTY CM_TEST_DEPENDENCIES) + target_link_libraries(${TARGET} ${DEPS}) +endfunction() + + +function(cm_test) + set(options COMPILE_ONLY WILL_FAIL NO_TEST_LIBS) + set(oneValueArgs NAME SOURCES_PREFIX) + set(multiValueArgs SOURCES CONTENT ARGS) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (PARSE_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to cm_test(): \"${PARSE_UNPARSED_ARGUMENTS}\"") + endif () + + set(SOURCES ${PARSE_SOURCES}) + + if (PARSE_NAME) + set(TEST_NAME ${PARSE_NAME}) + else () + string(MAKE_C_IDENTIFIER "${CMAKE_WORKSPACE_NAME}_${PROJECT_NAME}_${SOURCES}_test" TEST_NAME) + endif () + + if (PARSE_CONTENT) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generated-${TEST_NAME}.cpp "${PARSE_CONTENT}") + set(SOURCES ${CMAKE_CURRENT_BINARY_DIR}/generated-${TEST_NAME}.cpp) + endif () + + if (PARSE_COMPILE_ONLY) + add_library(${TEST_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES}) + add_test(NAME ${TEST_NAME} + COMMAND ${CMAKE_COMMAND} --build . --target ${TEST_NAME} --config $ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + if (PARSE_SOURCES_PREFIX) + target_include_directories(${TEST_NAME} PRIVATE ${PARSE_SOURCES_PREFIX}) + else () + target_include_directories(${TEST_NAME} PRIVATE .) + endif () + + # set_tests_properties(${TEST_NAME} PROPERTIES RESOURCE_LOCK cm_test_compile_only) + else () + add_executable(${TEST_NAME} ${SOURCES}) + cm_mark_as_test(${TEST_NAME}) + if (PARSE_SOURCES_PREFIX) + target_include_directories(${TEST_NAME} PRIVATE ${PARSE_SOURCES_PREFIX}) + else () + target_include_directories(${TEST_NAME} PRIVATE .) + endif () + if (WIN32) + foreach (CONFIG ${CMAKE_CONFIGURATION_TYPES} "") + file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}-test-run-${CONFIG}.cmake CONTENT " +include(\"${CMAKE_BINARY_DIR}/cm_set_rpath-$.cmake\") +if(CMAKE_CROSSCOMPILING) +foreach(RP \${RPATH}) + execute_process(COMMAND winepath -w \${RP} OUTPUT_VARIABLE _RPATH) + string(STRIP \"\${_RPATH}\" _RPATH) + set(ENV{WINEPATH} \"\${_RPATH};\$ENV{WINEPATH}\") +endforeach() +else() +set(ENV{PATH} \"\${RPATH};\$ENV{PATH}\") +endif() +execute_process( + COMMAND $ ${PARSE_ARGS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE RESULT) +if(NOT RESULT EQUAL 0) + message(FATAL_ERROR \"Test failed\") +endif() +" CONDITION $) + endforeach () + add_test(NAME ${TEST_NAME} COMMAND ${CMAKE_COMMAND} -DCMAKE_CROSSCOMPILING=${CMAKE_CROSSCOMPILING} -P ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}-test-run-$.cmake) + else () + add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME} ${PARSE_ARGS} WORKING_DIRECTORY .) + endif () + endif () + + if (BUILD_SHARED_LIBS) + target_compile_definitions(${TEST_NAME} PRIVATE -DBOOST_TEST_DYN_LINK=1 -DBOOST_TEST_NO_AUTO_LINK=1) + endif () + + if (PARSE_WILL_FAIL) + set_tests_properties(${TEST_NAME} PROPERTIES WILL_FAIL TRUE) + endif () + set_tests_properties(${TEST_NAME} PROPERTIES LABELS ${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) + if (NOT PARSE_NO_TEST_LIBS) + cm_target_link_test_libs(${TEST_NAME}) + endif () +endfunction(cm_test) + +function(cm_test_header) + set(options STATIC NO_TEST_LIBS) + set(oneValueArgs NAME HEADER) + set(multiValueArgs) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (PARSE_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to cm_test_header(): \"${PARSE_UNPARSED_ARGUMENTS}\"") + endif () + + if (PARSE_NAME) + set(TEST_NAME ${PARSE_NAME}) + else () + string(MAKE_C_IDENTIFIER "${CMAKE_WORKSPACE_NAME}_${PROJECT_NAME}_${PARSE_HEADER}_header_test" TEST_NAME) + endif () + + if (PARSE_STATIC) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/header-main-include-${TEST_NAME}.cpp + "#include <${PARSE_HEADER}>\nint main() {}\n" + ) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/header-static-include-${TEST_NAME}.cpp + "#include <${PARSE_HEADER}>\n" + ) + cm_test(NAME ${TEST_NAME} SOURCES + ${CMAKE_CURRENT_BINARY_DIR}/header-main-include-${TEST_NAME}.cpp + ${CMAKE_CURRENT_BINARY_DIR}/header-static-include-${TEST_NAME}.cpp + ) + else () + cm_test(NAME ${TEST_NAME} CONTENT + "#include <${PARSE_HEADER}>\nint main() {}\n" + ) + endif () + set_tests_properties(${TEST_NAME} PROPERTIES LABELS ${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) +endfunction(cm_test_header) + +macro(cm_add_test_subdirectory) + get_directory_property(_enable_tests_property ENABLE_TESTS) + get_property(_enable_tests_global_property GLOBAL PROPERTY ENABLE_TESTS) + string(TOUPPER "${_enable_tests_property}" _enable_tests_property_upper) + if (_enable_tests_property_upper STREQUAL "OFF" OR _enable_tests_property_upper EQUAL 1) + set(CURRENT_SOURCES_DIR ${CURRENT_SOURCES_DIR}/test) + add_subdirectory(${ARGN}) + endif () +endmacro() diff --git a/cmake/modules/share/modules/cmake/CMToSnakeCase.cmake b/cmake/modules/share/modules/cmake/CMToSnakeCase.cmake new file mode 100644 index 0000000000..ebb49a0bfd --- /dev/null +++ b/cmake/modules/share/modules/cmake/CMToSnakeCase.cmake @@ -0,0 +1,11 @@ + +function(to_snake_case str var) + # insert an underscore before any upper case letter + # which is not followed by another upper case letter + string(REGEX REPLACE "(.)([A-Z][a-z]+)" "\\1_\\2" value "${str}") + # insert an underscore before any upper case letter + # which is preseded by a lower case letter or number + string(REGEX REPLACE "([a-z0-9])([A-Z])" "\\1_\\2" value "${value}") + string(TOLOWER "${value}" value) + set(${var} "${value}" PARENT_SCOPE) +endfunction() diff --git a/cmake/modules/share/modules/cmake/version.hpp b/cmake/modules/share/modules/cmake/version.hpp new file mode 100644 index 0000000000..3162ea4af6 --- /dev/null +++ b/cmake/modules/share/modules/cmake/version.hpp @@ -0,0 +1,10 @@ + +#ifndef @PREFIX@_GUARD_VERSION_HPP +#define @PREFIX@_GUARD_VERSION_HPP + +#define @PREFIX@_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define @PREFIX@_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define @PREFIX@_VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define @PREFIX@_VERSION (((@PREFIX@_VERSION_MAJOR) << 24) + ((@PREFIX@_VERSION_MINOR) << 16) + (@PREFIX@_VERSION_PATCH)) + +#endif diff --git a/cmake/modules/test/CMakeLists.txt b/cmake/modules/test/CMakeLists.txt new file mode 100644 index 0000000000..4e7eb32658 --- /dev/null +++ b/cmake/modules/test/CMakeLists.txt @@ -0,0 +1,43 @@ + +cmake_policy(SET CMP0057 NEW) + +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/tmp) + +set(SKIP_TESTS) + +if(DEFINED ENV{APPVEYOR}) + list(APPEND SKIP_TESTS + pass-basic + pass-simplecustomname + pass-simplenamespace + pass-simple-test + ) +endif() + +function(create_test NAME TEST) + set(CONTEXT) + # get_cmake_property(VARS VARIABLES) + foreach(VAR_NAME CMAKE_TOOLCHAIN_FILE CMAKE_CROSSCOMPILING) + list(APPEND CONTEXT -D${VAR_NAME}=${${VAR_NAME}}) + endforeach() + add_custom_target(${NAME} COMMAND ${CMAKE_COMMAND} ${CONTEXT} -P test.cmake ${TEST} ${CMAKE_CURRENT_BINARY_DIR}/tmp/${NAME}) + if(NAME IN_LIST SKIP_TESTS) + add_test(NAME ${NAME} COMMAND echo skipped) + set_tests_properties(${NAME} properties DISABLED On) + else() + add_test(NAME ${NAME} COMMAND ${CMAKE_COMMAND} ${CONTEXT} -P test.cmake ${TEST} ${CMAKE_CURRENT_BINARY_DIR}/tmp/${NAME}) + endif() +endfunction() + +file(GLOB PASS_TESTS pass/*.cmake) +foreach(TEST ${PASS_TESTS}) + get_filename_component(NAME ${TEST} NAME_WE) + create_test(pass-${NAME} ${TEST}) +endforeach() + +file(GLOB FAIL_TESTS fail/*.cmake) +foreach(TEST ${FAIL_TESTS}) + get_filename_component(NAME ${TEST} NAME_WE) + create_test(fail-${NAME} ${TEST}) + set_tests_properties(fail-${NAME} properties WILL_FAIL On) +endforeach() diff --git a/cmake/modules/test/basicapp/CMakeLists.txt b/cmake/modules/test/basicapp/CMakeLists.txt new file mode 100644 index 0000000000..a01732a487 --- /dev/null +++ b/cmake/modules/test/basicapp/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.5) +project(basicapp) + +find_package(CM) + +include(CMInstallTargets) +include(CMDeploy) +include(CMTest) +include(CMSetupVersion) + +cm_setup_version(VERSION 1.0) + +find_package(simple) +add_executable(basicapp main.cpp) +target_link_libraries(basicapp simple) + +cm_install_targets(TARGETS basicapp) + +cm_test(NAME basciapptest SOURCES main.cpp) +target_link_libraries(basciapptest simple) + diff --git a/cmake/modules/test/basicapp/main.cpp b/cmake/modules/test/basicapp/main.cpp new file mode 100644 index 0000000000..e13f624519 --- /dev/null +++ b/cmake/modules/test/basicapp/main.cpp @@ -0,0 +1,6 @@ +#include +#include + +int main() { + simple(); +} diff --git a/cmake/modules/test/checkprop/CMakeLists.txt b/cmake/modules/test/checkprop/CMakeLists.txt new file mode 100644 index 0000000000..3eb74b41d5 --- /dev/null +++ b/cmake/modules/test/checkprop/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.5) +project(checkprop) + +find_package(CM) + +include(CMProperties) + +get_property(CURRENT_PROP_VAL GLOBAL PROPERTY ${PROP_NAME}) + +if(NOT "${CURRENT_PROP_VAL}" STREQUAL "${PROP_VALUE}") + message(FATAL_ERROR "Property ${PROP_NAME} set to ${CURRENT_PROP_VAL}, expected ${PROP_VALUE}") +endif() diff --git a/cmake/modules/test/fail/simple-test.cmake b/cmake/modules/test/fail/simple-test.cmake new file mode 100644 index 0000000000..87a780664f --- /dev/null +++ b/cmake/modules/test/fail/simple-test.cmake @@ -0,0 +1 @@ +install_dir(${TEST_DIR}/simpletest TARGETS check CMAKE_ARGS -DCMAKE_ENABLE_TESTS=Off) diff --git a/cmake/modules/test/findpackagecheck/CMakeLists.txt b/cmake/modules/test/findpackagecheck/CMakeLists.txt new file mode 100644 index 0000000000..4d64882eb2 --- /dev/null +++ b/cmake/modules/test/findpackagecheck/CMakeLists.txt @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 3.5) +project(findpackagecheck) + +message(STATUS "PKG: ${PKG}") +message(STATUS "PKG_TARGET: ${PKG_TARGET}") + +find_package(${PKG}) + +configure_file(main.cpp.in main.cpp @ONLY) + +add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.cpp) +target_link_libraries(main ${PKG_TARGET}) +install(TARGETS main DESTINATION bin) + diff --git a/cmake/modules/test/findpackagecheck/main.cpp.in b/cmake/modules/test/findpackagecheck/main.cpp.in new file mode 100644 index 0000000000..4c79ac8545 --- /dev/null +++ b/cmake/modules/test/findpackagecheck/main.cpp.in @@ -0,0 +1,4 @@ +#include <@PKG_HEADER@> + +int main() { +} diff --git a/cmake/modules/test/libbasic/CMakeLists.txt b/cmake/modules/test/libbasic/CMakeLists.txt new file mode 100644 index 0000000000..edf8b3ed81 --- /dev/null +++ b/cmake/modules/test/libbasic/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.5) +project(basic) + +find_package(CM) + +include(CMInstallTargets) +include(CMDeploy) +include(CMTest) +include(CMSetupVersion) + +cm_setup_version(VERSION 1.0) + +find_package(simple REQUIRED) +add_library(basic main.cpp) +target_link_libraries(basic simple) + +cm_deploy(TARGETS basic) + +cm_test(NAME basictest SOURCES test.cpp) +target_link_libraries(basictest basic) + diff --git a/cmake/modules/test/libbasic/main.cpp b/cmake/modules/test/libbasic/main.cpp new file mode 100644 index 0000000000..b31f723fab --- /dev/null +++ b/cmake/modules/test/libbasic/main.cpp @@ -0,0 +1,6 @@ +#include +#include + +inline void basic() { + simple(); +} diff --git a/cmake/modules/test/libbasic/test.cpp b/cmake/modules/test/libbasic/test.cpp new file mode 100644 index 0000000000..b2f997621b --- /dev/null +++ b/cmake/modules/test/libbasic/test.cpp @@ -0,0 +1,2 @@ +int main() { +} diff --git a/cmake/modules/test/libbasicnamespace/CMakeLists.txt b/cmake/modules/test/libbasicnamespace/CMakeLists.txt new file mode 100644 index 0000000000..ef821740f3 --- /dev/null +++ b/cmake/modules/test/libbasicnamespace/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.5) +project(basic) + +find_package(CM) + +include(CMInstallTargets) +include(CMDeploy) +include(CMTest) +include(CMSetupVersion) + +cm_setup_version(VERSION 1.0) + +find_package(simple) +add_library(basic main.cpp) +target_link_libraries(basic lib::simple) + +cm_deploy(TARGETS basic NAMESPACE lib::) + +cm_test(NAME basictest SOURCES test.cpp) +target_link_libraries(basictest basic) + diff --git a/cmake/modules/test/libbasicnamespace/main.cpp b/cmake/modules/test/libbasicnamespace/main.cpp new file mode 100644 index 0000000000..4f4ca4ee45 --- /dev/null +++ b/cmake/modules/test/libbasicnamespace/main.cpp @@ -0,0 +1,5 @@ +#include + +inline void basic() { + simple(); +} diff --git a/cmake/modules/test/libbasicnamespace/test.cpp b/cmake/modules/test/libbasicnamespace/test.cpp new file mode 100644 index 0000000000..b2f997621b --- /dev/null +++ b/cmake/modules/test/libbasicnamespace/test.cpp @@ -0,0 +1,2 @@ +int main() { +} diff --git a/cmake/modules/test/libsimple/CMakeLists.txt b/cmake/modules/test/libsimple/CMakeLists.txt new file mode 100644 index 0000000000..ae73d456bc --- /dev/null +++ b/cmake/modules/test/libsimple/CMakeLists.txt @@ -0,0 +1,51 @@ +cmake_minimum_required(VERSION 3.5) +project(simple) + +find_package(CM) + +include(CMInstallTargets) +include(CMDeploy) +include(CMSetupVersion) +include(CMTest) +include(CMPkgConfig) + +cm_setup_version(VERSION 1.0 GENERATE_HEADER simpleversion.hpp) + +find_package(Threads) + +add_library(simple INTERFACE) +target_include_directories(simple INTERFACE $/include2>) +target_compile_definitions(simple INTERFACE -DSOME_DEFINE=1 -DHAS_SIMPLE=1 -DDEFINE_3=3) +target_link_libraries(simple INTERFACE Threads::Threads) +if(NOT MSVC) + target_compile_options(simple INTERFACE -std=c++0x) +endif() +cm_test_link_libraries(simple) +install(FILES test.cpp DESTINATION include2) +cm_deploy(TARGETS simple include include) + +cm_test(NAME simpletest SOURCES test.cpp) + +cm_test(SOURCES test.cpp) + +cm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) + +cm_test(SOURCES compiletest.cpp COMPILE_ONLY) + +cm_test(NAME testwillfail SOURCES testwillfail.cpp WILL_FAIL) + +cm_test(SOURCES testwillfail.cpp WILL_FAIL) + +cm_test(NAME simpletestcompilewillfail SOURCES compiletestwillfail.cpp COMPILE_ONLY WILL_FAIL) + +cm_test(SOURCES compiletestwillfail.cpp COMPILE_ONLY WILL_FAIL) + +cm_test_header(NAME simpletestheader HEADER simple.h) + +cm_test_header(HEADER simple.h) + +cm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) + +add_library(simpletestinterface INTERFACE) +cm_mark_as_test(simpletestinterface) + diff --git a/cmake/modules/test/libsimple/compiletest.cpp b/cmake/modules/test/libsimple/compiletest.cpp new file mode 100644 index 0000000000..081fde1f49 --- /dev/null +++ b/cmake/modules/test/libsimple/compiletest.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main() { + std::abort(); + simple(); +} \ No newline at end of file diff --git a/cmake/modules/test/libsimple/compiletestwillfail.cpp b/cmake/modules/test/libsimple/compiletestwillfail.cpp new file mode 100644 index 0000000000..edde8b46ca --- /dev/null +++ b/cmake/modules/test/libsimple/compiletestwillfail.cpp @@ -0,0 +1,6 @@ +#include +#include + +int main() { + static_assert(false, "Error"); +} \ No newline at end of file diff --git a/cmake/modules/test/libsimple/include/simple.h b/cmake/modules/test/libsimple/include/simple.h new file mode 100644 index 0000000000..36ccbff7a4 --- /dev/null +++ b/cmake/modules/test/libsimple/include/simple.h @@ -0,0 +1,22 @@ +#ifndef GUARD_SIMPLE_H +#define GUARD_SIMPLE_H + +#ifndef __MINGW32__ + +#include + +#endif + +#if !defined(HAS_SIMPLE) || DEFINE_3 != 3 +#error "Not configured" +#endif + +inline void simple() { +#ifndef __MINGW32__ + std::thread([] { + }).join(); +#endif +} + + +#endif diff --git a/cmake/modules/test/libsimple/test.cpp b/cmake/modules/test/libsimple/test.cpp new file mode 100644 index 0000000000..c2a02710dc --- /dev/null +++ b/cmake/modules/test/libsimple/test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + simple(); +} diff --git a/cmake/modules/test/libsimple/testwillfail.cpp b/cmake/modules/test/libsimple/testwillfail.cpp new file mode 100644 index 0000000000..789dcc908a --- /dev/null +++ b/cmake/modules/test/libsimple/testwillfail.cpp @@ -0,0 +1,6 @@ +#include +#include + +int main() { + return 1; +} diff --git a/cmake/modules/test/libsimplecustomname/CMakeLists.txt b/cmake/modules/test/libsimplecustomname/CMakeLists.txt new file mode 100644 index 0000000000..4f05a39168 --- /dev/null +++ b/cmake/modules/test/libsimplecustomname/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.5) +project(libsimple) + +find_package(CM) + +include(CMInstallTargets) +include(CMDeploy) +include(CMSetupVersion) +include(CMTest) + +cm_setup_version(VERSION 1.0 GENERATE_HEADER simpleversion.hpp) + +add_library(simple INTERFACE) + +cm_install_targets(TARGETS simple include include) +cm_auto_export(TARGETS simple NAME simple) + +cm_test(NAME simpletest SOURCES test.cpp) +target_link_libraries(simpletest simple) + +cm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) +target_link_libraries(simpletestcompile simple) + +cm_test_header(NAME simpletestheader HEADER simple.h) +target_link_libraries(simpletestheader simple) + +cm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) +target_link_libraries(simpleteststaticheader simple) + diff --git a/cmake/modules/test/libsimplecustomname/compiletest.cpp b/cmake/modules/test/libsimplecustomname/compiletest.cpp new file mode 100644 index 0000000000..081fde1f49 --- /dev/null +++ b/cmake/modules/test/libsimplecustomname/compiletest.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main() { + std::abort(); + simple(); +} \ No newline at end of file diff --git a/cmake/modules/test/libsimplecustomname/include/simple.h b/cmake/modules/test/libsimplecustomname/include/simple.h new file mode 100644 index 0000000000..1449d6b212 --- /dev/null +++ b/cmake/modules/test/libsimplecustomname/include/simple.h @@ -0,0 +1,8 @@ +#ifndef GUARD_SIMPLE_H +#define GUARD_SIMPLE_H + +inline void simple() { +} + + +#endif diff --git a/cmake/modules/test/libsimplecustomname/test.cpp b/cmake/modules/test/libsimplecustomname/test.cpp new file mode 100644 index 0000000000..c2a02710dc --- /dev/null +++ b/cmake/modules/test/libsimplecustomname/test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + simple(); +} diff --git a/cmake/modules/test/libsimplenamespace/CMakeLists.txt b/cmake/modules/test/libsimplenamespace/CMakeLists.txt new file mode 100644 index 0000000000..96bf3b4bd1 --- /dev/null +++ b/cmake/modules/test/libsimplenamespace/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.5) +project(simple) + +find_package(CM) + +include(CMInstallTargets) +include(CMDeploy) +include(CMSetupVersion) +include(CMTest) + +cm_setup_version(VERSION 1.0) + +add_library(simple INTERFACE) +target_compile_definitions(simple INTERFACE -DHAS_SIMPLE=1) +cm_deploy(TARGETS simple include include NAMESPACE lib::) + +cm_test(NAME simpletest SOURCES test.cpp) +target_link_libraries(simpletest lib::simple) + +cm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) +target_link_libraries(simpletestcompile lib::simple) + +cm_test_header(NAME simpletestheader HEADER simple.h) +target_link_libraries(simpletestheader lib::simple) + +cm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) +target_link_libraries(simpleteststaticheader lib::simple) + diff --git a/cmake/modules/test/libsimplenamespace/compiletest.cpp b/cmake/modules/test/libsimplenamespace/compiletest.cpp new file mode 100644 index 0000000000..081fde1f49 --- /dev/null +++ b/cmake/modules/test/libsimplenamespace/compiletest.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main() { + std::abort(); + simple(); +} \ No newline at end of file diff --git a/cmake/modules/test/libsimplenamespace/include/simple.h b/cmake/modules/test/libsimplenamespace/include/simple.h new file mode 100644 index 0000000000..24936d3f55 --- /dev/null +++ b/cmake/modules/test/libsimplenamespace/include/simple.h @@ -0,0 +1,12 @@ +#ifndef GUARD_SIMPLE_H +#define GUARD_SIMPLE_H + +#ifndef HAS_SIMPLE +#error "Not configured" +#endif + +inline void simple() { +} + + +#endif diff --git a/cmake/modules/test/libsimplenamespace/test.cpp b/cmake/modules/test/libsimplenamespace/test.cpp new file mode 100644 index 0000000000..c2a02710dc --- /dev/null +++ b/cmake/modules/test/libsimplenamespace/test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + simple(); +} diff --git a/cmake/modules/test/parseversion/CMakeLists.txt b/cmake/modules/test/parseversion/CMakeLists.txt new file mode 100644 index 0000000000..5152778d81 --- /dev/null +++ b/cmake/modules/test/parseversion/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.5) +project(simple) + +find_package(CM) + +include(CMInstallTargets) +include(CMDeploy) +include(CMSetupVersion) +include(CMTest) + +cm_setup_version(PARSE_HEADER include/version.h) + +if(NOT "${PROJECT_VERSION}" STREQUAL "2.3.5") + message(SEND_ERROR "Incorrect version was parsed: ${PROJECT_VERSION}") +endif() + +add_library(simple INTERFACE) + +cm_install_targets(TARGETS simple include include) + +cm_test(NAME simpletest SOURCES test.cpp) +target_link_libraries(simpletest simple) + +cm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) +target_link_libraries(simpletestcompile simple) + +cm_test_header(NAME simpletestheader HEADER simple.h) +target_link_libraries(simpletestheader simple) + +cm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) +target_link_libraries(simpleteststaticheader simple) + diff --git a/cmake/modules/test/parseversion/compiletest.cpp b/cmake/modules/test/parseversion/compiletest.cpp new file mode 100644 index 0000000000..081fde1f49 --- /dev/null +++ b/cmake/modules/test/parseversion/compiletest.cpp @@ -0,0 +1,7 @@ +#include +#include + +int main() { + std::abort(); + simple(); +} \ No newline at end of file diff --git a/cmake/modules/test/parseversion/include/simple.h b/cmake/modules/test/parseversion/include/simple.h new file mode 100644 index 0000000000..8c6da42152 --- /dev/null +++ b/cmake/modules/test/parseversion/include/simple.h @@ -0,0 +1,10 @@ +#ifndef GUARD_SIMPLE_H +#define GUARD_SIMPLE_H + +#include "version.h" + +inline void simple() { +} + + +#endif diff --git a/cmake/modules/test/parseversion/include/version.h b/cmake/modules/test/parseversion/include/version.h new file mode 100644 index 0000000000..a1f525ba83 --- /dev/null +++ b/cmake/modules/test/parseversion/include/version.h @@ -0,0 +1,8 @@ +#ifndef GUARD_VERSION_H +#define GUARD_VERSION_H + +#define SIMPLE_VERSION_MAJOR 2 +#define SIMPLE_VERSION_MINOR 3 +#define SIMPLE_VERSION_PATCH 5 + +#endif diff --git a/cmake/modules/test/parseversion/test.cpp b/cmake/modules/test/parseversion/test.cpp new file mode 100644 index 0000000000..c2a02710dc --- /dev/null +++ b/cmake/modules/test/parseversion/test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + simple(); +} diff --git a/cmake/modules/test/pass/basic.cmake b/cmake/modules/test/pass/basic.cmake new file mode 100644 index 0000000000..6f989d2824 --- /dev/null +++ b/cmake/modules/test/pass/basic.cmake @@ -0,0 +1,6 @@ +install_dir(${TEST_DIR}/libsimple TARGETS check) +install_dir(${TEST_DIR}/libbasic TARGETS check) +test_check_package(NAME simple HEADER simple.h TARGET simple) +test_check_pkgconfig(NAME simple HEADER simple.h) +test_check_package(NAME basic HEADER simple.h TARGET basic) +test_check_pkgconfig(NAME basic HEADER simple.h) diff --git a/cmake/modules/test/pass/defaultproperties.cmake b/cmake/modules/test/pass/defaultproperties.cmake new file mode 100644 index 0000000000..e2d941f10e --- /dev/null +++ b/cmake/modules/test/pass/defaultproperties.cmake @@ -0,0 +1,15 @@ +macro(check_prop PROP_NAME VAR_NAME PROP_VALUE) + build_dir(${TEST_DIR}/checkprop CMAKE_ARGS + -D${VAR_NAME}=${PROP_VALUE} + -DPROP_NAME=${PROP_NAME} + -DPROP_VALUE=${PROP_VALUE}) +endmacro() + +foreach(VALUE On Off 1 0) + check_prop(CXX_EXCEPTIONS CMAKE_CXX_EXCEPTIONS ${VALUE}) + check_prop(CXX_RTTI CMAKE_CXX_RTTI ${VALUE}) + check_prop(CXX_STATIC_RUNTIME CMAKE_CXX_STATIC_RUNTIME ${VALUE}) + check_prop(CXX_WARNINGS CMAKE_CXX_WARNINGS ${VALUE}) + check_prop(CXX_WARNINGS_AS_ERRORS CMAKE_CXX_WARNINGS_AS_ERRORS ${VALUE}) +endforeach() +check_prop(CXX_WARNINGS CMAKE_CXX_WARNINGS ALL) \ No newline at end of file diff --git a/cmake/modules/test/pass/parseversion.cmake b/cmake/modules/test/pass/parseversion.cmake new file mode 100644 index 0000000000..8c2a3c2397 --- /dev/null +++ b/cmake/modules/test/pass/parseversion.cmake @@ -0,0 +1 @@ +install_dir(${TEST_DIR}/parseversion TARGETS check) diff --git a/cmake/modules/test/pass/properties.cmake b/cmake/modules/test/pass/properties.cmake new file mode 100644 index 0000000000..01f8ffa741 --- /dev/null +++ b/cmake/modules/test/pass/properties.cmake @@ -0,0 +1 @@ +install_dir(${TEST_DIR}/properties TARGETS check) diff --git a/cmake/modules/test/pass/simple-shared.cmake b/cmake/modules/test/pass/simple-shared.cmake new file mode 100644 index 0000000000..58a1b9c178 --- /dev/null +++ b/cmake/modules/test/pass/simple-shared.cmake @@ -0,0 +1,4 @@ +install_dir(${TEST_DIR}/libsimple TARGETS check CMAKE_ARGS -DBUILD_SHARED_LIBS=On) +install_dir(${TEST_DIR}/basicapp TARGETS check CMAKE_ARGS -DBUILD_SHARED_LIBS=On) +test_check_package(NAME simple HEADER simple.h TARGET simple) +test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simple-test-build.cmake b/cmake/modules/test/pass/simple-test-build.cmake new file mode 100644 index 0000000000..659f4adc9a --- /dev/null +++ b/cmake/modules/test/pass/simple-test-build.cmake @@ -0,0 +1,3 @@ +install_dir(${TEST_DIR}/simpletest TARGETS check CMAKE_ARGS -DBUILD_TESTING=On) +test_check_package(NAME simple HEADER simple.h TARGET simple) +test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simple-test-shared.cmake b/cmake/modules/test/pass/simple-test-shared.cmake new file mode 100644 index 0000000000..4eee4fae1d --- /dev/null +++ b/cmake/modules/test/pass/simple-test-shared.cmake @@ -0,0 +1,3 @@ +install_dir(${TEST_DIR}/simpletest TARGETS check CMAKE_ARGS -DBUILD_SHARED_LIBS=On -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=On) +test_check_package(NAME simple HEADER simple.h TARGET simple CMAKE_ARGS -DBUILD_SHARED_LIBS=On -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=On) +test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simple-test.cmake b/cmake/modules/test/pass/simple-test.cmake new file mode 100644 index 0000000000..11dec266d9 --- /dev/null +++ b/cmake/modules/test/pass/simple-test.cmake @@ -0,0 +1,3 @@ +install_dir(${TEST_DIR}/simpletest TARGETS check) +test_check_package(NAME simple HEADER simple.h TARGET simple) +test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simple.cmake b/cmake/modules/test/pass/simple.cmake new file mode 100644 index 0000000000..63a895ecb1 --- /dev/null +++ b/cmake/modules/test/pass/simple.cmake @@ -0,0 +1,4 @@ +install_dir(${TEST_DIR}/libsimple TARGETS check) +install_dir(${TEST_DIR}/basicapp TARGETS check) +test_check_package(NAME simple HEADER simple.h TARGET simple) +test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simplecustomname.cmake b/cmake/modules/test/pass/simplecustomname.cmake new file mode 100644 index 0000000000..8325dfc001 --- /dev/null +++ b/cmake/modules/test/pass/simplecustomname.cmake @@ -0,0 +1,2 @@ +install_dir(${TEST_DIR}/libsimplecustomname TARGETS check) +install_dir(${TEST_DIR}/libbasic TARGETS check) \ No newline at end of file diff --git a/cmake/modules/test/pass/simplenamespace.cmake b/cmake/modules/test/pass/simplenamespace.cmake new file mode 100644 index 0000000000..079e737877 --- /dev/null +++ b/cmake/modules/test/pass/simplenamespace.cmake @@ -0,0 +1,2 @@ +install_dir(${TEST_DIR}/libsimplenamespace TARGETS check) +test_check_package(NAME simple HEADER simple.h TARGET lib::simple) diff --git a/cmake/modules/test/pass/superproject.cmake b/cmake/modules/test/pass/superproject.cmake new file mode 100644 index 0000000000..0cb7c103b7 --- /dev/null +++ b/cmake/modules/test/pass/superproject.cmake @@ -0,0 +1,5 @@ +install_dir(${TEST_DIR}/superproject TARGETS check) +test_check_package(NAME simple HEADER simple.h TARGET lib::simple) +test_check_pkgconfig(NAME simple HEADER simple.h) +test_check_package(NAME basic HEADER simple.h TARGET lib::basic) +test_check_pkgconfig(NAME basic HEADER simple.h) \ No newline at end of file diff --git a/cmake/modules/test/pkgconfigcheck/CMakeLists.txt b/cmake/modules/test/pkgconfigcheck/CMakeLists.txt new file mode 100644 index 0000000000..5f59a7b632 --- /dev/null +++ b/cmake/modules/test/pkgconfigcheck/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 3.5) +project(pkgconfigcheck) + +find_package(CM) + +include(CMInstallTargets) +include(CMDeploy) +include(CMSetupVersion) +include(CMTest) +include(CMPkgConfig) + +set(_pkgconfig_path) +foreach(PATH ${CMAKE_PREFIX_PATH}) + list(APPEND _pkgconfig_path ${PATH}/lib/pkgconfig) + list(APPEND _pkgconfig_path ${PATH}/share/pkgconfig) +endforeach() + +if(NOT "${_pkgconfig_path}" STREQUAL "") + # remove empty values from the list + list(REMOVE_ITEM _pkgconfig_path "") + file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path) + if(UNIX) + string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}") + string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}") + endif() + set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}") +endif() + +find_package(PkgConfig) +pkg_check_modules(PKGS REQUIRED ${PKG_CONFIG_MODULES}) + +cm_setup_version(VERSION 1.0 GENERATE_HEADER pkgconfigcheckversion.hpp) + +add_library(pkgconfigcheck INTERFACE) +target_compile_options(pkgconfigcheck INTERFACE ${PKGS_CFLAGS}) +target_link_libraries(pkgconfigcheck INTERFACE ${PKGS_LDFLAGS}) +cm_test_link_libraries(pkgconfigcheck) + +cm_install_targets(TARGETS pkgconfigcheck) +cm_auto_export(TARGETS pkgconfigcheck) + +if(DEFINED PKG_CONFIG_HEADER) + cm_test_header(NAME testheader HEADER ${PKG_CONFIG_HEADER}) + cm_test_header(NAME teststaticheader HEADER ${PKG_CONFIG_HEADER} STATIC) +endif() + diff --git a/cmake/modules/test/properties/CMakeLists.txt b/cmake/modules/test/properties/CMakeLists.txt new file mode 100644 index 0000000000..dd8c68453b --- /dev/null +++ b/cmake/modules/test/properties/CMakeLists.txt @@ -0,0 +1,67 @@ +cmake_minimum_required(VERSION 3.5) +project(properties) + +find_package(CM) + +include(CMProperties) +include(CMSetupVersion) +include(CMDeploy) +include(CMTest) + +cm_setup_version(VERSION 1.0) + +add_library(simple INTERFACE) + +cm_install_targets(TARGETS simple include include) +cm_auto_export(TARGETS simple) +cm_auto_pkgconfig(TARGET simple) + +if(MSVC) + add_compile_options(/we4541) + add_compile_options(/we4530) +endif() + +cm_test_link_libraries(simple) + +cm_test(NAME simpletest SOURCES test.cpp) + +cm_test(NAME rttitest SOURCES test.cpp) +set_target_properties(rttitest PROPERTIES CXX_RTTI FALSE) + +cm_test(NAME exceptiontest SOURCES test.cpp) +set_target_properties(exceptiontest PROPERTIES CXX_EXCEPTIONS FALSE) + +cm_test(NAME statictest SOURCES test.cpp) +set_target_properties(statictest PROPERTIES CXX_STATIC_RUNTIME TRUE) + +cm_test(NAME throw SOURCES throw.cpp COMPILE_ONLY WILL_FAIL) +set_target_properties(throw PROPERTIES CXX_EXCEPTIONS FALSE) + +cm_test(NAME throwpass SOURCES throw.cpp) +set_target_properties(throwpass PROPERTIES CXX_EXCEPTIONS TRUE) + +cm_test(NAME rtti SOURCES rtti.cpp COMPILE_ONLY WILL_FAIL) +set_target_properties(rtti PROPERTIES CXX_RTTI FALSE) + +cm_test(NAME rttipass SOURCES rtti.cpp) +set_target_properties(rttipass PROPERTIES CXX_RTTI TRUE) + +foreach(WARNING_LEVEL FALSE TRUE all) + cm_test(NAME warnings-${WARNING_LEVEL} SOURCES warnings.cpp) + set_target_properties(warnings-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) + + if(WARNING_LEVEL STREQUAL "FALSE") + cm_test(NAME warnings-errors-${WARNING_LEVEL} SOURCES warnings.cpp COMPILE_ONLY) + else() + cm_test(NAME warnings-errors-${WARNING_LEVEL} SOURCES warnings.cpp COMPILE_ONLY WILL_FAIL) + endif() + set_target_properties(warnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) + set_target_properties(warnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS_AS_ERRORS TRUE) + + cm_test(NAME nowarnings-${WARNING_LEVEL} SOURCES nowarnings.cpp) + set_target_properties(nowarnings-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) + + cm_test(NAME nowarnings-errors-${WARNING_LEVEL} SOURCES nowarnings.cpp) + set_target_properties(nowarnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) + set_target_properties(nowarnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS_AS_ERRORS TRUE) +endforeach() diff --git a/cmake/modules/test/properties/include/simple.h b/cmake/modules/test/properties/include/simple.h new file mode 100644 index 0000000000..1449d6b212 --- /dev/null +++ b/cmake/modules/test/properties/include/simple.h @@ -0,0 +1,8 @@ +#ifndef GUARD_SIMPLE_H +#define GUARD_SIMPLE_H + +inline void simple() { +} + + +#endif diff --git a/cmake/modules/test/properties/nowarnings.cpp b/cmake/modules/test/properties/nowarnings.cpp new file mode 100644 index 0000000000..fe9ea520e4 --- /dev/null +++ b/cmake/modules/test/properties/nowarnings.cpp @@ -0,0 +1,5 @@ +int main() { + // Unused variable + int i = 0; + (void) i; +} diff --git a/cmake/modules/test/properties/rtti.cpp b/cmake/modules/test/properties/rtti.cpp new file mode 100644 index 0000000000..c73196c4b0 --- /dev/null +++ b/cmake/modules/test/properties/rtti.cpp @@ -0,0 +1,20 @@ +struct base { + virtual ~base() { + } +}; + +struct A : base { +}; + +struct B : base { +}; + +int main() { + base *x = new A(); + B *y = dynamic_cast(x); + if (y != 0) { + return -1; + } else { + return 0; + } +} diff --git a/cmake/modules/test/properties/test.cpp b/cmake/modules/test/properties/test.cpp new file mode 100644 index 0000000000..c2a02710dc --- /dev/null +++ b/cmake/modules/test/properties/test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + simple(); +} diff --git a/cmake/modules/test/properties/throw.cpp b/cmake/modules/test/properties/throw.cpp new file mode 100644 index 0000000000..9dfc806303 --- /dev/null +++ b/cmake/modules/test/properties/throw.cpp @@ -0,0 +1,6 @@ +int main() { + try { + throw "up"; + } catch (...) { + } +} diff --git a/cmake/modules/test/properties/warnings.cpp b/cmake/modules/test/properties/warnings.cpp new file mode 100644 index 0000000000..f13d2ed47b --- /dev/null +++ b/cmake/modules/test/properties/warnings.cpp @@ -0,0 +1,9 @@ +struct A; + +class A { +}; // C4099 + +int main() { + // Unused variable + int i = 0; +} diff --git a/cmake/modules/test/simpletest/CMakeLists.txt b/cmake/modules/test/simpletest/CMakeLists.txt new file mode 100644 index 0000000000..d19348cecd --- /dev/null +++ b/cmake/modules/test/simpletest/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.5) +project(simple) + +find_package(CM) + +include(CMInstallTargets) +include(CMDeploy) +include(CMTest) +include(CMSetupVersion) + +cm_setup_version(VERSION 1.0) + +add_library(simple simple.cpp) +target_include_directories(simple PRIVATE $) + +cm_deploy(TARGETS simple include include) + +cm_test(NAME simpletoptest SOURCES test.cpp) +target_link_libraries(simpletoptest simple) + +cm_add_test_subdirectory(test) + +if(TARGET simpletest) + message(FATAL_ERROR "simpletest was not added") +endif() + diff --git a/cmake/modules/test/simpletest/include/simple.h b/cmake/modules/test/simpletest/include/simple.h new file mode 100644 index 0000000000..84cc1a2e27 --- /dev/null +++ b/cmake/modules/test/simpletest/include/simple.h @@ -0,0 +1 @@ +void simple(); diff --git a/cmake/modules/test/simpletest/simple.cpp b/cmake/modules/test/simpletest/simple.cpp new file mode 100644 index 0000000000..88660cd7eb --- /dev/null +++ b/cmake/modules/test/simpletest/simple.cpp @@ -0,0 +1,4 @@ +#include + +void simple() { +} diff --git a/cmake/modules/test/simpletest/test.cpp b/cmake/modules/test/simpletest/test.cpp new file mode 100644 index 0000000000..c2a02710dc --- /dev/null +++ b/cmake/modules/test/simpletest/test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + simple(); +} diff --git a/cmake/modules/test/simpletest/test/CMakeLists.txt b/cmake/modules/test/simpletest/test/CMakeLists.txt new file mode 100644 index 0000000000..d4b91e9048 --- /dev/null +++ b/cmake/modules/test/simpletest/test/CMakeLists.txt @@ -0,0 +1,7 @@ +cm_test_link_libraries(simple) + +if(NOT BUILD_TESTING) + cm_test_link_libraries(foo::non_existent) +endif() + +cm_test(NAME simpletest SOURCES test.cpp) diff --git a/cmake/modules/test/simpletest/test/test.cpp b/cmake/modules/test/simpletest/test/test.cpp new file mode 100644 index 0000000000..c2a02710dc --- /dev/null +++ b/cmake/modules/test/simpletest/test/test.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + simple(); +} diff --git a/cmake/modules/test/superproject/CMakeLists.txt b/cmake/modules/test/superproject/CMakeLists.txt new file mode 100644 index 0000000000..8ce520d9d5 --- /dev/null +++ b/cmake/modules/test/superproject/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.5) +project(superproject) + +find_package(CM) +include(CMIgnorePackage) + +cm_ignore_package(simple) + +add_subdirectory(../libbasicnamespace libbasicnamespace) +add_subdirectory(../libsimplenamespace libsimplenamespace) diff --git a/cmake/modules/test/test.cmake b/cmake/modules/test/test.cmake new file mode 100644 index 0000000000..ec6c355d94 --- /dev/null +++ b/cmake/modules/test/test.cmake @@ -0,0 +1,124 @@ + +if(CMAKE_ARGC LESS 5) + message(FATAL_ERROR "Not enough parameters to test.cmake") +endif() + +math(EXPR TMP_ARGN "${CMAKE_ARGC}-1") +math(EXPR TEST_ARGN "${TMP_ARGN}-1") + +string(RANDOM _TEST_RAND) +set(TEST ${CMAKE_ARGV${TEST_ARGN}}) +set(TEST_DIR .) +set(TMP_DIR ${CMAKE_ARGV${TMP_ARGN}}-${_TEST_RAND}) +file(MAKE_DIRECTORY ${TMP_DIR}) +set(PREFIX ${TMP_DIR}/usr) +set(BUILDS_DIR ${TMP_DIR}/builds) +# message("TMP_DIR: ${TMP_DIR}") + +if(NOT EXISTS ${TEST}) + message(FATAL_ERROR "Test ${TEST} does not exist") +endif() + +macro(test_expect_eq X Y) + if(NOT ${X} EQUAL ${Y}) + message(FATAL_ERROR "EXPECT FAILURE: ${X} != ${Y}") + endif() +endmacro() + +macro(test_expect_file FILE) + if(NOT EXISTS ${FILE}) + message(FATAL_ERROR "EXPECT FILE: ${FILE}") + endif() +endmacro() + +function(test_exec) + string(REPLACE ";" " " OUTPUT "${ARGN}") + message(${OUTPUT}) + execute_process(${ARGN} RESULT_VARIABLE RESULT) + if(NOT RESULT EQUAL 0) + message(FATAL_ERROR "Process failed: ${OUTPUT}") + endif() +endfunction() + +function(install_dir DIR) + set(options NO_INSTALL) + set(oneValueArgs) + set(multiValueArgs CMAKE_ARGS TARGETS) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + string(RANDOM BUILD_RAND) + set(BUILD_DIR ${BUILDS_DIR}/${BUILD_RAND}) + if(NOT EXISTS ${BUILD_DIR}) + file(MAKE_DIRECTORY ${BUILD_DIR}) + endif() + if(CMAKE_TOOLCHAIN_FILE) + set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + endif() + test_exec(COMMAND ${CMAKE_COMMAND} + -DCMAKE_PREFIX_PATH=${PREFIX} + -DCMAKE_INSTALL_PREFIX=${PREFIX} + -DTHREADS_PREFER_PTHREAD_FLAG=1 + ${TOOLCHAIN_ARG} + ${PARSE_CMAKE_ARGS} + ${DIR} + WORKING_DIRECTORY ${BUILD_DIR} + ) + test_exec(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR}) + foreach(TARGET ${PARSE_TARGETS}) + test_exec(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR} --target ${TARGET}) + endforeach() + if(NOT PARSE_NO_INSTALL) + test_exec(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR} --target install) + endif() + + file(REMOVE_RECURSE ${BUILD_DIR}) +endfunction() + +function(build_dir DIR) + install_dir(${DIR} ${ARGN} NO_INSTALL) +endfunction() + +function(test_check_pkgconfig) + set(options) + set(oneValueArgs NAME HEADER) + set(multiValueArgs) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(HEADER_FLAG) + if(PARSE_HEADER) + set(HEADER_FLAG -DPKG_CONFIG_HEADER=${PARSE_HEADER}) + endif() + + # TODO: We really should check pkgconfig during cross compiling + if(NOT CMAKE_CROSSCOMPILING) + install_dir(${TEST_DIR}/pkgconfigcheck TARGETS check CMAKE_ARGS -DPKG_CONFIG_MODULES=${PARSE_NAME} ${HEADER_FLAG}) + endif() +endfunction() + +function(test_check_package) + set(options) + set(oneValueArgs NAME HEADER TARGET) + set(multiValueArgs) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(HEADER_FLAG) + if(PARSE_HEADER) + set(HEADER_FLAG -DPKG_HEADER=${PARSE_HEADER}) + endif() + + set(TARGET ${PARSE_NAME}) + if(PARSE_TARGET) + set(TARGET ${PARSE_TARGET}) + endif() + + install_dir(${TEST_DIR}/findpackagecheck CMAKE_ARGS -DPKG=${PARSE_NAME} -DPKG_TARGET=${TARGET} ${HEADER_FLAG}) +endfunction() + +install_dir(${TEST_DIR}/../) + +include(${TEST}) + +file(REMOVE_RECURSE ${TMP_DIR}) diff --git a/cmake/packages/FindCrypto3.cmake b/cmake/packages/FindCrypto3.cmake new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cmake/packages/FindValgrind.cmake b/cmake/packages/FindValgrind.cmake new file mode 100644 index 0000000000..82730b172b --- /dev/null +++ b/cmake/packages/FindValgrind.cmake @@ -0,0 +1,23 @@ +# Find Valgrind. +# +# This module defines: +# VALGRIND_INCLUDE_DIR, where to find valgrind/memcheck.h, etc. +# VALGRIND_PROGRAM, the valgrind executable. +# VALGRIND_FOUND, If false, do not try to use valgrind. +# +# If you have valgrind installed in a non-standard place, you can define +# VALGRIND_PREFIX to tell cmake_backup where it is. +# +# NOTE: Copied from the opencog project, where it is distributed under the +# terms of the New BSD License. + +find_path(VALGRIND_INCLUDE_DIR valgrind/memcheck.h + /usr/include /usr/local/include ${VALGRIND_PREFIX}/include) +find_program(VALGRIND_PROGRAM NAMES valgrind PATH + /usr/bin /usr/local/bin ${VALGRIND_PREFIX}/bin) + +find_package_handle_standard_args(VALGRIND DEFAULT_MSG + VALGRIND_INCLUDE_DIR + VALGRIND_PROGRAM) + +mark_as_advanced(VALGRIND_INCLUDE_DIR VALGRIND_PROGRAM) \ No newline at end of file diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000000..5962fd1eda --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,56 @@ +#---------------------------------------------------------------------------// +# MIT License +# +# Copyright (c) 2020 Mikhail Komarov +# Copyright (c) 2022 Aleksei Moskvin +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +#---------------------------------------------------------------------------// + + +#include_directories("../include" +# "${CMAKE_CURRENT_BINARY_DIR}/include" +# +# ${Boost_INCLUDE_DIRS}) + +macro(define_containers_example example) + get_filename_component(name ${example} NAME) + string(REPLACE "-" "_" target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${name}_example) + + add_executable(${target_name} ${example}.cpp) + target_link_libraries(${target_name} PRIVATE + ${CMAKE_WORKSPACE_NAME}::core + ${CMAKE_WORKSPACE_NAME}::network + ${CMAKE_WORKSPACE_NAME}::containers + epoll-shim + + crypto3::algebra + crypto3::hash + crypto3::containers + + ${Boost_LIBRARIES}) + set_target_properties(${target_name} PROPERTIES CXX_STANDARD 17) +endmacro() + +set(EXAMPLES_NAMES + "merkle/merkle") + +foreach(EXAMPLE_NAME ${EXAMPLES_NAMES}) + define_containers_example(${EXAMPLE_NAME}) +endforeach() diff --git a/example/merkle/merkle.cpp b/example/merkle/merkle.cpp new file mode 100644 index 0000000000..4f76cc1de8 --- /dev/null +++ b/example/merkle/merkle.cpp @@ -0,0 +1,100 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2020 Mikhail Komarov +// Copyright (c) 2021-2022 Aleksei Moskvin +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +//#include +//#include +#include +// +#include +#include +//#include +// +#include +#include +#include +#include + +#include + +#include +#include + +#include + +using namespace nil::crypto3; +using namespace nil::crypto3::containers_actor; + +struct config { + nil::actor::sstring name = "App"; + nil::actor::sstring description = ""; + std::chrono::duration default_task_quota = std::chrono::microseconds(500); + bool auto_handle_sigint_sigterm = true; + + config() { + } +}; +static nil::actor::reactor_config reactor_config_from_app_config(config cfg) { + nil::actor::reactor_config ret; + ret.auto_handle_sigint_sigterm = cfg.auto_handle_sigint_sigterm; + ret.task_quota = cfg.default_task_quota; + return ret; +}; + +int main(int argc, char **argv) { + nil::actor::app_template app; + app.run(argc, argv, [] {return nil::actor::async([] { + std::vector > data_on_leafs = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; + std::array element_not_in_tree = {'9'}; + nil::crypto3::containers::merkle_tree, 3> tree = nil::actor::containers::make_merkle_tree, 3>(data_on_leafs.begin(), data_on_leafs.end()); + + nil::crypto3::containers::merkle_proof, 3> proof_leaf_3(tree, 3); + nil::crypto3::containers::merkle_proof, 3> proof_leaf_0(tree, 0); + + std::vector> data_to_check = {{data_on_leafs[2]}, {data_on_leafs[0]}, {data_on_leafs[3]}, element_not_in_tree}; + for (size_t i = 0; i < data_to_check.size(); ++i) { + std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 0: "; + std::cout << std::boolalpha << proof_leaf_0.validate(data_to_check[i]) << std::endl; + std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 3: "; + std::cout << std::boolalpha << proof_leaf_3.validate(data_to_check[i]) << std::endl; + } + + std::array left = {'\x6d', '\x65', '\x73', '\x73', '\x61', '\x67', '\x65'}; + std::array right = {'\x20', '\x64', '\x69', '\x67', '\x65', '\x73', '\x74'}; + std::vector > simple_binary_tree_data = {left, right}; + nil::crypto3::containers::merkle_tree, 2> simple_binary_tree = nil::actor::containers::make_merkle_tree, 2>(simple_binary_tree_data.begin(), simple_binary_tree_data.end()); + nil::crypto3::containers::merkle_proof, 2> simple_binary_proof_leaf_1(simple_binary_tree, 1); + // std::cout << "Tree simple binary structure:" << std::endl; + // std::cout << simple_binary_tree << std::endl; + std::cout << "Is leaf " << data_on_leafs[1][0] << " was in tree in position 1: "; + std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(data_on_leafs[1]) << std::endl; + std::cout << "Is leaf left was in tree in position 1: "; + std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(left) << std::endl; + std::cout << "Is leaf right was in tree in position 1: "; + std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(right) << std::endl; + + + return 0;}); + }); +} \ No newline at end of file diff --git a/include/nil/crypto3/container_actor/merkle/tree.hpp b/include/nil/crypto3/container_actor/merkle/tree.hpp new file mode 100644 index 0000000000..997dfaf959 --- /dev/null +++ b/include/nil/crypto3/container_actor/merkle/tree.hpp @@ -0,0 +1,123 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2020 Mikhail Komarov +// Copyright (c) 2021-2022 Aleksei Moskvin +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#ifndef ACTOR_MERKLE_TREE_HPP +#define ACTOR_MERKLE_TREE_HPP + +#include +#include + +#include + +#include +#include + +#include + +#include +#include +#include + +#include + +#include + +namespace nil { + namespace actor { + namespace containers { + namespace detail { + + // nil::actor::future<> f() { + // return nil::actor::parallel_for_each( + // boost::irange(0, nil::actor::smp::count), + // [](unsigned c) { return nil::actor::smp::submit_to(c, service_loop); }); + // } + + template + containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { + typedef T node_type; + typedef typename node_type::hash_type hash_type; + typedef typename node_type::value_type value_type; + + containers::detail::merkle_tree_impl ret(std::distance(first, last)); + + ret.reserve(ret.complete_size()); + + while (first != last) { + ret.emplace_back(crypto3::hash(*first++)); + } + + // ret.resize(ret.complete_size()); + + std::size_t row_size = ret.leaves() / Arity; + typename containers::detail::merkle_tree_impl::iterator it = ret.begin(); + + for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { + std::vector>> fut; + std::size_t parallels = std::min((std::size_t)nil::actor::smp::count, row_size); + std::size_t node_per_shard = row_size / parallels; + + for (auto c = 0; c < parallels; ++c) { + auto begin_row = node_per_shard * c; + auto end_row = std::min(node_per_shard * (c + 1), row_size); + auto it_c = it + node_per_shard * c * Arity; + + fut.push_back(nil::actor::smp::submit_to(c, [begin_row, end_row, it_c] { + std::vector res; + for (size_t i = 0; i < end_row - begin_row; ++i) { + res.push_back(nil::crypto3::containers::detail::generate_hash( + it_c + i * Arity, it_c + (i + 1) * Arity)); + } + return nil::actor::make_ready_future>(res); + })); + } + + it += Arity * row_size; + + for (auto &i : fut) { + std::vector v = i.get(); + for (std::size_t j = 0; j < v.size(); ++j) { + ret.emplace_back(v[j]); + std::cout << v[j] << std::endl; + } + } + } + return ret; + } + } // namespace detail + + template + nil::crypto3::containers::merkle_tree make_merkle_tree(LeafIterator first, LeafIterator last) { + return detail::make_merkle_tree< + typename std::conditional::value, + nil::crypto3::containers::detail::merkle_tree_node, T>::type, + Arity>(first, last); + } + + } // namespace containers + } // namespace actor +} // namespace nil + +#endif // ACTOR_MERKLE_TREE_HPP diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000..4cecb4bd1c --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,160 @@ +#---------------------------------------------------------------------------// +# MIT License +# +# Copyright (c) 2020 Mikhail Komarov +# Copyright (c) 2021-2022 Aleksei Moskvin +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +#---------------------------------------------------------------------------// + +include(CMTest) + +if (NOT Boost_UNIT_TEST_FRAMEWORK_FOUND) + cm_find_package(Boost REQUIRED COMPONENTS unit_test_framework) +endif () + +cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} + ${CMAKE_WORKSPACE_NAME}::core + ${CMAKE_WORKSPACE_NAME}::network + ${CMAKE_WORKSPACE_NAME}::testing + epoll-shim + + crypto3::algebra + crypto3::hash + crypto3::containers + + ${Boost_LIBRARIES}) + +macro(define_storage_test test) + get_filename_component(name ${test} NAME) + string(REPLACE "-" "_" target_name ${CURRENT_PROJECT_NAME}_${name}_test) + + while (TARGET ${target_name}) + get_filename_component(TEST_DIRECTORY ${test} DIRECTORY) + get_filename_component(PARENT_DIR ${TEST_DIRECTORY} DIRECTORY) + set(target_name ${PARENT_DIR}_${target_name}) + endwhile () + + cm_test(NAME ${target_name} SOURCES ${test}.cpp) + + target_include_directories(${target_name} PRIVATE + "$" + "$" + + ${Boost_INCLUDE_DIRS}) + + set_target_properties(${target_name} PROPERTIES CXX_STANDARD 17) + + get_target_property(target_type Boost::unit_test_framework TYPE) + if (target_type STREQUAL "SHARED_LIB") + target_compile_definitions(${target_name} PRIVATE BOOST_TEST_DYN_LINK) + elseif (target_type STREQUAL "STATIC_LIB") + + endif () +endmacro() + +set(TESTS_NAMES + "merkle/merkle" + ) + +foreach (TEST_NAME ${TESTS_NAMES}) + define_storage_test(${TEST_NAME}) +endforeach () + + +function(actor_add_test name) + set(test_kinds + ACTOR + BOOST + CUSTOM) + + cmake_parse_arguments(parsed_args + "" + "WORKING_DIRECTORY;KIND" + "RUN_ARGS;SOURCES;LIBRARIES;DEPENDS" + ${ARGN}) + + if(NOT parsed_args_KIND) + set(parsed_args_KIND ACTOR) + elseif(NOT (parsed_args_KIND IN_LIST test_kinds)) + message(FATAL_ERROR "Invalid test kind. KIND must be one of ${test_kinds}") + endif() + + if(parsed_args_SOURCES) + # + # Each kind of test must populate the `args` and `libraries` lists. + # + + set(libraries "${parsed_args_LIBRARIES}") + + set(args "") + if(parsed_args_KIND STREQUAL "ACTOR") + list(APPEND libraries + actor::core + actor::network + ${CMAKE_WORKSPACE_NAME}::testing) + + list(APPEND args -- -c ${BUILD_WITH_UNIT_TEST_SMP}) + elseif(parsed_args_KIND STREQUAL "BOOST") + list(APPEND libraries + ${CMAKE_WORKSPACE_NAME}::core + ${CMAKE_WORKSPACE_NAME}::network + ${CMAKE_WORKSPACE_NAME}::testing) + endif() + + if(NOT (UNIX AND (CMAKE_SYSTEM_NAME STREQUAL "Linux"))) + list(APPEND libraries epoll-shim) + endif() + + list(APPEND args ${parsed_args_RUN_ARGS}) + + cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} + ${libraries} + ${Boost_LIBRARIES}) + + cm_test(NAME ${CMAKE_WORKSPACE_NAME}_${name}_test SOURCES ${parsed_args_SOURCES}) + + target_compile_definitions(${CMAKE_WORKSPACE_NAME}_${name}_test PRIVATE + ACTOR_TESTING_MAIN BOOST_TEST_DYN_LINK) + + if((BUILD_WITH_STACK_GUARDS STREQUAL "ON") OR + ((BUILD_WITH_STACK_GUARDS STREQUAL "DEFAULT") AND + (CMAKE_BUILD_TYPE IN_LIST ACTOR_STACK_GUARD_MODES))) + target_compile_definitions(${CMAKE_WORKSPACE_NAME}_${name}_test + PRIVATE ACTOR_THREAD_STACK_GUARDS) + endif() + + target_include_directories(${CMAKE_WORKSPACE_NAME}_${name}_test PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${BUILD_WITH_SOURCE_DIR}/src) + + set_target_properties(${CMAKE_WORKSPACE_NAME}_${name}_test PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED TRUE) + + target_compile_options(${CMAKE_WORKSPACE_NAME}_${name}_test PRIVATE + ${${CURRENT_PROJECT_NAME}_PRIVATE_CXX_FLAGS}) + else() + if(NOT (parsed_args_KIND STREQUAL "CUSTOM")) + message(FATAL_ERROR "SOURCES are required for ${parsed_args_KIND} tests") + endif() + endif() +endfunction() + +actor_add_test(merkle_actor_zerg SOURCES merkle/merkle.cpp) \ No newline at end of file diff --git a/test/merkle/merkle.cpp b/test/merkle/merkle.cpp new file mode 100644 index 0000000000..b46fa542c3 --- /dev/null +++ b/test/merkle/merkle.cpp @@ -0,0 +1,43 @@ +////---------------------------------------------------------------------------// +//// Copyright (c) 2018-2020 Mikhail Komarov +//// Copyright (c) 2021-2022 Aleksei Moskvin +//// +//// MIT License +//// +//// Permission is hereby granted, free of charge, to any person obtaining a copy +//// of this software and associated documentation files (the "Software"), to deal +//// in the Software without restriction, including without limitation the rights +//// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +//// copies of the Software, and to permit persons to whom the Software is +//// furnished to do so, subject to the following conditions: +//// +//// The above copyright notice and this permission notice shall be included in all +//// copies or substantial portions of the Software. +//// +//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +//// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +//// SOFTWARE. +////---------------------------------------------------------------------------// + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +using namespace nil::actor; + +ACTOR_TEST_CASE(merkletree_actor_test) { + BOOST_ASSERT(1 == 1); + return make_ready_future<>(); +} \ No newline at end of file From 8dbba21631118cfbf2d8af7fc93ad0be248b7786 Mon Sep 17 00:00:00 2001 From: Zerg1996 Date: Sat, 14 May 2022 16:47:18 +0200 Subject: [PATCH 02/23] Namespaces renames --- CMakeLists.txt | 2 +- example/merkle/merkle.cpp | 2 +- .../container_actor => actor/container}/merkle/tree.hpp | 6 +++--- test/CMakeLists.txt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename include/nil/{crypto3/container_actor => actor/container}/merkle/tree.hpp (93%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 584e304652..45c212c70d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,9 +82,9 @@ set_target_properties(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} PROPERTIES EXPORT_NAME ${CURRENT_PROJECT_NAME}) target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE - epoll-shim ${CMAKE_WORKSPACE_NAME}::network ${CMAKE_WORKSPACE_NAME}::core +# epoll-shim crypto3::algebra crypto3::hash diff --git a/example/merkle/merkle.cpp b/example/merkle/merkle.cpp index 4f76cc1de8..13c557912f 100644 --- a/example/merkle/merkle.cpp +++ b/example/merkle/merkle.cpp @@ -44,7 +44,7 @@ #include using namespace nil::crypto3; -using namespace nil::crypto3::containers_actor; +using namespace nil::crypto3::containers; struct config { nil::actor::sstring name = "App"; diff --git a/include/nil/crypto3/container_actor/merkle/tree.hpp b/include/nil/actor/container/merkle/tree.hpp similarity index 93% rename from include/nil/crypto3/container_actor/merkle/tree.hpp rename to include/nil/actor/container/merkle/tree.hpp index 997dfaf959..1808b014a0 100644 --- a/include/nil/crypto3/container_actor/merkle/tree.hpp +++ b/include/nil/actor/container/merkle/tree.hpp @@ -56,12 +56,12 @@ namespace nil { // } template - containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { + nil::crypto3::containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { typedef T node_type; typedef typename node_type::hash_type hash_type; typedef typename node_type::value_type value_type; - containers::detail::merkle_tree_impl ret(std::distance(first, last)); + nil::crypto3::containers::detail::merkle_tree_impl ret(std::distance(first, last)); ret.reserve(ret.complete_size()); @@ -72,7 +72,7 @@ namespace nil { // ret.resize(ret.complete_size()); std::size_t row_size = ret.leaves() / Arity; - typename containers::detail::merkle_tree_impl::iterator it = ret.begin(); + typename nil::crypto3::containers::detail::merkle_tree_impl::iterator it = ret.begin(); for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { std::vector>> fut; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4cecb4bd1c..ce7a9dddca 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -33,7 +33,7 @@ cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} ${CMAKE_WORKSPACE_NAME}::core ${CMAKE_WORKSPACE_NAME}::network ${CMAKE_WORKSPACE_NAME}::testing - epoll-shim +# epoll-shim crypto3::algebra crypto3::hash From eae8af8d6d6d017238c70f89da58c915afd17088 Mon Sep 17 00:00:00 2001 From: Zerg1996 Date: Sat, 14 May 2022 20:43:54 +0200 Subject: [PATCH 03/23] Simplify cmake actor add test --- test/CMakeLists.txt | 101 +++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 66 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ce7a9dddca..f6bcab8a22 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -29,56 +29,10 @@ if (NOT Boost_UNIT_TEST_FRAMEWORK_FOUND) cm_find_package(Boost REQUIRED COMPONENTS unit_test_framework) endif () -cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} - ${CMAKE_WORKSPACE_NAME}::core - ${CMAKE_WORKSPACE_NAME}::network - ${CMAKE_WORKSPACE_NAME}::testing -# epoll-shim - - crypto3::algebra - crypto3::hash - crypto3::containers - - ${Boost_LIBRARIES}) - -macro(define_storage_test test) - get_filename_component(name ${test} NAME) - string(REPLACE "-" "_" target_name ${CURRENT_PROJECT_NAME}_${name}_test) - - while (TARGET ${target_name}) - get_filename_component(TEST_DIRECTORY ${test} DIRECTORY) - get_filename_component(PARENT_DIR ${TEST_DIRECTORY} DIRECTORY) - set(target_name ${PARENT_DIR}_${target_name}) - endwhile () - - cm_test(NAME ${target_name} SOURCES ${test}.cpp) - - target_include_directories(${target_name} PRIVATE - "$" - "$" - - ${Boost_INCLUDE_DIRS}) - - set_target_properties(${target_name} PROPERTIES CXX_STANDARD 17) - - get_target_property(target_type Boost::unit_test_framework TYPE) - if (target_type STREQUAL "SHARED_LIB") - target_compile_definitions(${target_name} PRIVATE BOOST_TEST_DYN_LINK) - elseif (target_type STREQUAL "STATIC_LIB") - - endif () -endmacro() - -set(TESTS_NAMES - "merkle/merkle" - ) - -foreach (TEST_NAME ${TESTS_NAMES}) - define_storage_test(${TEST_NAME}) -endforeach () - - function(actor_add_test name) + get_filename_component(test_name ${name} NAME) + set(target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${test_name}_test) + set(test_kinds ACTOR BOOST @@ -102,20 +56,20 @@ function(actor_add_test name) # set(libraries "${parsed_args_LIBRARIES}") + list(APPEND libraries + ${CMAKE_WORKSPACE_NAME}::core + ${CMAKE_WORKSPACE_NAME}::network + ${CMAKE_WORKSPACE_NAME}::testing +# epoll-shim + + crypto3::algebra + crypto3::hash + crypto3::containers) + set(args "") if(parsed_args_KIND STREQUAL "ACTOR") - list(APPEND libraries - actor::core - actor::network - ${CMAKE_WORKSPACE_NAME}::testing) - list(APPEND args -- -c ${BUILD_WITH_UNIT_TEST_SMP}) - elseif(parsed_args_KIND STREQUAL "BOOST") - list(APPEND libraries - ${CMAKE_WORKSPACE_NAME}::core - ${CMAKE_WORKSPACE_NAME}::network - ${CMAKE_WORKSPACE_NAME}::testing) endif() if(NOT (UNIX AND (CMAKE_SYSTEM_NAME STREQUAL "Linux"))) @@ -128,33 +82,48 @@ function(actor_add_test name) ${libraries} ${Boost_LIBRARIES}) - cm_test(NAME ${CMAKE_WORKSPACE_NAME}_${name}_test SOURCES ${parsed_args_SOURCES}) + cm_test(NAME ${target_name} SOURCES ${parsed_args_SOURCES}) - target_compile_definitions(${CMAKE_WORKSPACE_NAME}_${name}_test PRIVATE + target_compile_definitions(${target_name} PRIVATE ACTOR_TESTING_MAIN BOOST_TEST_DYN_LINK) if((BUILD_WITH_STACK_GUARDS STREQUAL "ON") OR ((BUILD_WITH_STACK_GUARDS STREQUAL "DEFAULT") AND (CMAKE_BUILD_TYPE IN_LIST ACTOR_STACK_GUARD_MODES))) - target_compile_definitions(${CMAKE_WORKSPACE_NAME}_${name}_test + target_compile_definitions(${target_name} PRIVATE ACTOR_THREAD_STACK_GUARDS) endif() - target_include_directories(${CMAKE_WORKSPACE_NAME}_${name}_test PRIVATE + target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${BUILD_WITH_SOURCE_DIR}/src) - set_target_properties(${CMAKE_WORKSPACE_NAME}_${name}_test PROPERTIES + set_target_properties(${target_name} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED TRUE) - target_compile_options(${CMAKE_WORKSPACE_NAME}_${name}_test PRIVATE + target_compile_options(${target_name} PRIVATE ${${CURRENT_PROJECT_NAME}_PRIVATE_CXX_FLAGS}) + + get_target_property(target_type Boost::unit_test_framework TYPE) + if (target_type STREQUAL "SHARED_LIB") + target_compile_definitions(${target_name} PRIVATE BOOST_TEST_DYN_LINK) + elseif (target_type STREQUAL "STATIC_LIB") + + endif () else() if(NOT (parsed_args_KIND STREQUAL "CUSTOM")) message(FATAL_ERROR "SOURCES are required for ${parsed_args_KIND} tests") endif() endif() + + endfunction() -actor_add_test(merkle_actor_zerg SOURCES merkle/merkle.cpp) \ No newline at end of file +set(TESTS_NAMES + "merkle/merkle" + ) + +foreach (TEST_NAME ${TESTS_NAMES}) + actor_add_test(${TEST_NAME} SOURCES ${TEST_NAME}.cpp) +endforeach () \ No newline at end of file From b2c9a90b3fbcf9d0470350617a8c7864ca365924 Mon Sep 17 00:00:00 2001 From: Zerg1996 Date: Sat, 14 May 2022 20:44:20 +0200 Subject: [PATCH 04/23] Added tests --- example/CMakeLists.txt | 12 +-- include/nil/actor/container/merkle/tree.hpp | 8 +- test/merkle/merkle.cpp | 111 ++++++++++++++++++-- 3 files changed, 116 insertions(+), 15 deletions(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 5962fd1eda..272260a0fa 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -24,21 +24,21 @@ #---------------------------------------------------------------------------// -#include_directories("../include" -# "${CMAKE_CURRENT_BINARY_DIR}/include" -# -# ${Boost_INCLUDE_DIRS}) +include_directories("../include" + "${CMAKE_CURRENT_BINARY_DIR}/include" + + ${Boost_INCLUDE_DIRS}) macro(define_containers_example example) get_filename_component(name ${example} NAME) - string(REPLACE "-" "_" target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${name}_example) + set(target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${test_name}_example) add_executable(${target_name} ${example}.cpp) target_link_libraries(${target_name} PRIVATE ${CMAKE_WORKSPACE_NAME}::core ${CMAKE_WORKSPACE_NAME}::network ${CMAKE_WORKSPACE_NAME}::containers - epoll-shim +# epoll-shim crypto3::algebra crypto3::hash diff --git a/include/nil/actor/container/merkle/tree.hpp b/include/nil/actor/container/merkle/tree.hpp index 1808b014a0..0000b0299d 100644 --- a/include/nil/actor/container/merkle/tree.hpp +++ b/include/nil/actor/container/merkle/tree.hpp @@ -79,9 +79,12 @@ namespace nil { std::size_t parallels = std::min((std::size_t)nil::actor::smp::count, row_size); std::size_t node_per_shard = row_size / parallels; - for (auto c = 0; c < parallels; ++c) { + for (std::size_t c = 0; c < parallels; ++c) { auto begin_row = node_per_shard * c; - auto end_row = std::min(node_per_shard * (c + 1), row_size); + auto end_row = node_per_shard * (c + 1); + if (c == parallels - 1) { + end_row = row_size; + } auto it_c = it + node_per_shard * c * Arity; fut.push_back(nil::actor::smp::submit_to(c, [begin_row, end_row, it_c] { @@ -100,7 +103,6 @@ namespace nil { std::vector v = i.get(); for (std::size_t j = 0; j < v.size(); ++j) { ret.emplace_back(v[j]); - std::cout << v[j] << std::endl; } } } diff --git a/test/merkle/merkle.cpp b/test/merkle/merkle.cpp index b46fa542c3..c0ff3eee1a 100644 --- a/test/merkle/merkle.cpp +++ b/test/merkle/merkle.cpp @@ -23,21 +23,120 @@ //// SOFTWARE. ////---------------------------------------------------------------------------// +#include +#include +#include +//#include +//#include + #include +#include #include #include -#include #include +#include +#include +#include + #include -#include -#include #include +template +typename std::enable_if::value, std::vector>>::type + generate_random_data(std::size_t leaf_number) { + std::vector> v; + for (std::size_t i = 0; i < leaf_number; ++i) { + std::array leaf {}; + std::generate(std::begin(leaf), std::end(leaf), + [&]() { return std::rand() % (std::numeric_limits::max() + 1); }); + v.emplace_back(leaf); + } + return v; +} + +template +void testing_validate_template_random_data(std::size_t leaf_number) { + std::array data_not_in_tree = {0}; + auto data = generate_random_data(leaf_number); + auto tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()); + + std::size_t proof_idx = std::rand() % leaf_number; + nil::crypto3::containers::merkle_proof proof(tree, proof_idx); + bool good_validate = proof.validate(data[proof_idx]); + bool wrong_leaf_validate = proof.validate(data[(proof_idx + 1) % leaf_number]); + bool wrong_data_validate = proof.validate(data_not_in_tree); + BOOST_CHECK(good_validate); + BOOST_CHECK(!wrong_leaf_validate); + BOOST_CHECK(!wrong_data_validate); +} + +template +void testing_validate_template(std::vector data) { + std::array data_not_in_tree = {'\x6d', '\x65', '\x73', '\x73', '\x61', '\x67', '\x65'}; + nil::crypto3::containers::merkle_tree tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()); + nil::crypto3::containers::merkle_proof proof(tree, 0); + bool good_validate = proof.validate(data[0]); + bool wrong_leaf_validate = proof.validate(data[1]); + bool wrong_data_validate = proof.validate(data_not_in_tree); + BOOST_CHECK(true == good_validate); + BOOST_CHECK(false == wrong_leaf_validate); + BOOST_CHECK(false == wrong_data_validate); +} + +template +void testing_hash_template(std::vector data, std::string result) { + nil::crypto3::containers::merkle_tree tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()); + BOOST_CHECK(result == std::to_string(tree.root())); +} + using namespace nil::actor; -ACTOR_TEST_CASE(merkletree_actor_test) { - BOOST_ASSERT(1 == 1); - return make_ready_future<>(); +ACTOR_THREAD_TEST_CASE(merkletree_validate_test_1) { + std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}}; + testing_validate_template, 2>(v); + testing_validate_template(v); + testing_validate_template, 2>(v); + + std::size_t leaf_number = 64; + testing_validate_template_random_data, 2, std::uint8_t, 1>(leaf_number); + testing_validate_template_random_data(leaf_number); + testing_validate_template_random_data, 2, std::uint8_t, 1>(leaf_number); +} + +ACTOR_THREAD_TEST_CASE(merkletree_validate_test_2) { + std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; + testing_validate_template, 3>(v); + testing_validate_template(v); + testing_validate_template, 3>(v); + + std::size_t leaf_number = 81; + testing_validate_template_random_data, 3, std::uint8_t, 1>(leaf_number); + testing_validate_template_random_data(leaf_number); + testing_validate_template_random_data, 3, std::uint8_t, 1>(leaf_number); +} + +//ACTOR_THREAD_TEST_CASE(merkletree_validate_test_3) { +// using hash_type = nil::crypto3::hashes::pedersen< +// nil::crypto3::hashes::find_group_hash_default_params, nil::crypto3::hashes::sha2<256>, +// nil::crypto3::algebra::curves::jubjub::template g1_type>; +// std::size_t leaf_number = 8; +// testing_validate_template_random_data(leaf_number); +// return make_ready_future<>(); +//} + +ACTOR_THREAD_TEST_CASE(merkletree_hash_test_1) { + std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}}; + testing_hash_template, 2>(v, "3b828c4f4b48c5d4cb5562a474ec9e2fd8d5546fae40e90732ef635892e42720"); + testing_hash_template(v, "11ee8b50825ce6f816a1ae06d4aa0045"); + testing_hash_template, 2>(v, "0ed2a2145cae554ca57f08420d6cb58629ca1e89dc92f819c6c1d13d"); +} + +ACTOR_THREAD_TEST_CASE(merkletree_hash_test_2) { + std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; + testing_hash_template, 3>(v, "6831d4d32538bedaa7a51970ac10474d5884701c840781f0a434e5b6868d4b73"); + testing_hash_template(v, "0733c4cd580b1523cfbb9751f42e9420"); + testing_hash_template, 3>(v, "d9d0ff26d10aaac2882c08eb2b55e78690c949d1a73b1cfc0eb322ee"); } \ No newline at end of file From 6d49fa674f159a480366769a0fc5cc3537921bcb Mon Sep 17 00:00:00 2001 From: Zerg1996 Date: Sun, 15 May 2022 21:54:26 +0200 Subject: [PATCH 05/23] Minor style fixes --- example/merkle/merkle.cpp | 93 +++++++++------------ include/nil/actor/container/merkle/tree.hpp | 3 +- 2 files changed, 40 insertions(+), 56 deletions(-) diff --git a/example/merkle/merkle.cpp b/example/merkle/merkle.cpp index 13c557912f..2324888e29 100644 --- a/example/merkle/merkle.cpp +++ b/example/merkle/merkle.cpp @@ -22,23 +22,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. //---------------------------------------------------------------------------// - -//#include -//#include #include -// + #include #include -//#include -// -#include + #include -#include #include - #include - -#include #include #include @@ -46,55 +37,47 @@ using namespace nil::crypto3; using namespace nil::crypto3::containers; -struct config { - nil::actor::sstring name = "App"; - nil::actor::sstring description = ""; - std::chrono::duration default_task_quota = std::chrono::microseconds(500); - bool auto_handle_sigint_sigterm = true; - - config() { - } -}; -static nil::actor::reactor_config reactor_config_from_app_config(config cfg) { - nil::actor::reactor_config ret; - ret.auto_handle_sigint_sigterm = cfg.auto_handle_sigint_sigterm; - ret.task_quota = cfg.default_task_quota; - return ret; -}; - int main(int argc, char **argv) { nil::actor::app_template app; - app.run(argc, argv, [] {return nil::actor::async([] { - std::vector > data_on_leafs = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; - std::array element_not_in_tree = {'9'}; - nil::crypto3::containers::merkle_tree, 3> tree = nil::actor::containers::make_merkle_tree, 3>(data_on_leafs.begin(), data_on_leafs.end()); - - nil::crypto3::containers::merkle_proof, 3> proof_leaf_3(tree, 3); - nil::crypto3::containers::merkle_proof, 3> proof_leaf_0(tree, 0); + app.run(argc, argv, [] { + return nil::actor::async([] { + std::vector> data_on_leafs = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, + {'5'}, {'6'}, {'7'}, {'8'}}; + std::array element_not_in_tree = {'9'}; + nil::crypto3::containers::merkle_tree, 3> tree = + nil::actor::containers::make_merkle_tree, 3>(data_on_leafs.begin(), + data_on_leafs.end()); - std::vector> data_to_check = {{data_on_leafs[2]}, {data_on_leafs[0]}, {data_on_leafs[3]}, element_not_in_tree}; - for (size_t i = 0; i < data_to_check.size(); ++i) { - std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 0: "; - std::cout << std::boolalpha << proof_leaf_0.validate(data_to_check[i]) << std::endl; - std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 3: "; - std::cout << std::boolalpha << proof_leaf_3.validate(data_to_check[i]) << std::endl; - } + nil::crypto3::containers::merkle_proof, 3> proof_leaf_3(tree, 3); + nil::crypto3::containers::merkle_proof, 3> proof_leaf_0(tree, 0); - std::array left = {'\x6d', '\x65', '\x73', '\x73', '\x61', '\x67', '\x65'}; - std::array right = {'\x20', '\x64', '\x69', '\x67', '\x65', '\x73', '\x74'}; - std::vector > simple_binary_tree_data = {left, right}; - nil::crypto3::containers::merkle_tree, 2> simple_binary_tree = nil::actor::containers::make_merkle_tree, 2>(simple_binary_tree_data.begin(), simple_binary_tree_data.end()); - nil::crypto3::containers::merkle_proof, 2> simple_binary_proof_leaf_1(simple_binary_tree, 1); - // std::cout << "Tree simple binary structure:" << std::endl; - // std::cout << simple_binary_tree << std::endl; - std::cout << "Is leaf " << data_on_leafs[1][0] << " was in tree in position 1: "; - std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(data_on_leafs[1]) << std::endl; - std::cout << "Is leaf left was in tree in position 1: "; - std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(left) << std::endl; - std::cout << "Is leaf right was in tree in position 1: "; - std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(right) << std::endl; + std::vector> data_to_check = { + {data_on_leafs[2]}, {data_on_leafs[0]}, {data_on_leafs[3]}, element_not_in_tree}; + for (size_t i = 0; i < data_to_check.size(); ++i) { + std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 0: "; + std::cout << std::boolalpha << proof_leaf_0.validate(data_to_check[i]) << std::endl; + std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 3: "; + std::cout << std::boolalpha << proof_leaf_3.validate(data_to_check[i]) << std::endl; + } + std::array left = {'\x6d', '\x65', '\x73', '\x73', '\x61', '\x67', '\x65'}; + std::array right = {'\x20', '\x64', '\x69', '\x67', '\x65', '\x73', '\x74'}; + std::vector> simple_binary_tree_data = {left, right}; + nil::crypto3::containers::merkle_tree, 2> simple_binary_tree = + nil::actor::containers::make_merkle_tree, 2>(simple_binary_tree_data.begin(), + simple_binary_tree_data.end()); + nil::crypto3::containers::merkle_proof, 2> simple_binary_proof_leaf_1( + simple_binary_tree, 1); + // std::cout << "Tree simple binary structure:" << std::endl; + // std::cout << simple_binary_tree << std::endl; + std::cout << "Is leaf " << data_on_leafs[1][0] << " was in tree in position 1: "; + std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(data_on_leafs[1]) << std::endl; + std::cout << "Is leaf left was in tree in position 1: "; + std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(left) << std::endl; + std::cout << "Is leaf right was in tree in position 1: "; + std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(right) << std::endl; - return 0;}); + return 0; + }); }); } \ No newline at end of file diff --git a/include/nil/actor/container/merkle/tree.hpp b/include/nil/actor/container/merkle/tree.hpp index 0000b0299d..3b89f11e14 100644 --- a/include/nil/actor/container/merkle/tree.hpp +++ b/include/nil/actor/container/merkle/tree.hpp @@ -56,7 +56,8 @@ namespace nil { // } template - nil::crypto3::containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { + nil::crypto3::containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, + LeafIterator last) { typedef T node_type; typedef typename node_type::hash_type hash_type; typedef typename node_type::value_type value_type; From fbf998b57d58b2a0dfcabb9c8447326aea3bb33d Mon Sep 17 00:00:00 2001 From: Zerg1996 Date: Mon, 16 May 2022 17:30:01 +0200 Subject: [PATCH 06/23] Return future instead class --- example/CMakeLists.txt | 10 +++++----- example/merkle/merkle.cpp | 4 ++-- include/nil/actor/container/merkle/tree.hpp | 18 +++++------------- test/merkle/merkle.cpp | 10 ++++------ 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 272260a0fa..05f3cd7ebd 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories("../include" ${Boost_INCLUDE_DIRS}) macro(define_containers_example example) - get_filename_component(name ${example} NAME) + get_filename_component(test_name ${example} NAME) set(target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${test_name}_example) add_executable(${target_name} ${example}.cpp) @@ -38,7 +38,7 @@ macro(define_containers_example example) ${CMAKE_WORKSPACE_NAME}::core ${CMAKE_WORKSPACE_NAME}::network ${CMAKE_WORKSPACE_NAME}::containers -# epoll-shim + epoll-shim crypto3::algebra crypto3::hash @@ -49,8 +49,8 @@ macro(define_containers_example example) endmacro() set(EXAMPLES_NAMES - "merkle/merkle") + "merkle/merkle") -foreach(EXAMPLE_NAME ${EXAMPLES_NAMES}) +foreach (EXAMPLE_NAME ${EXAMPLES_NAMES}) define_containers_example(${EXAMPLE_NAME}) -endforeach() +endforeach () diff --git a/example/merkle/merkle.cpp b/example/merkle/merkle.cpp index 2324888e29..682ca94f8e 100644 --- a/example/merkle/merkle.cpp +++ b/example/merkle/merkle.cpp @@ -46,7 +46,7 @@ int main(int argc, char **argv) { std::array element_not_in_tree = {'9'}; nil::crypto3::containers::merkle_tree, 3> tree = nil::actor::containers::make_merkle_tree, 3>(data_on_leafs.begin(), - data_on_leafs.end()); + data_on_leafs.end()).get(); nil::crypto3::containers::merkle_proof, 3> proof_leaf_3(tree, 3); nil::crypto3::containers::merkle_proof, 3> proof_leaf_0(tree, 0); @@ -65,7 +65,7 @@ int main(int argc, char **argv) { std::vector> simple_binary_tree_data = {left, right}; nil::crypto3::containers::merkle_tree, 2> simple_binary_tree = nil::actor::containers::make_merkle_tree, 2>(simple_binary_tree_data.begin(), - simple_binary_tree_data.end()); + simple_binary_tree_data.end()).get(); nil::crypto3::containers::merkle_proof, 2> simple_binary_proof_leaf_1( simple_binary_tree, 1); // std::cout << "Tree simple binary structure:" << std::endl; diff --git a/include/nil/actor/container/merkle/tree.hpp b/include/nil/actor/container/merkle/tree.hpp index 3b89f11e14..b5cfd80f74 100644 --- a/include/nil/actor/container/merkle/tree.hpp +++ b/include/nil/actor/container/merkle/tree.hpp @@ -48,16 +48,9 @@ namespace nil { namespace actor { namespace containers { namespace detail { - - // nil::actor::future<> f() { - // return nil::actor::parallel_for_each( - // boost::irange(0, nil::actor::smp::count), - // [](unsigned c) { return nil::actor::smp::submit_to(c, service_loop); }); - // } - template - nil::crypto3::containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, - LeafIterator last) { + nil::actor::future> + make_merkle_tree(LeafIterator first, LeafIterator last) { typedef T node_type; typedef typename node_type::hash_type hash_type; typedef typename node_type::value_type value_type; @@ -70,8 +63,6 @@ namespace nil { ret.emplace_back(crypto3::hash(*first++)); } - // ret.resize(ret.complete_size()); - std::size_t row_size = ret.leaves() / Arity; typename nil::crypto3::containers::detail::merkle_tree_impl::iterator it = ret.begin(); @@ -107,12 +98,13 @@ namespace nil { } } } - return ret; + return nil::actor::make_ready_future>(ret); } } // namespace detail template - nil::crypto3::containers::merkle_tree make_merkle_tree(LeafIterator first, LeafIterator last) { + nil::actor::future> make_merkle_tree(LeafIterator first, + LeafIterator last) { return detail::make_merkle_tree< typename std::conditional::value, nil::crypto3::containers::detail::merkle_tree_node, T>::type, diff --git a/test/merkle/merkle.cpp b/test/merkle/merkle.cpp index c0ff3eee1a..609ffcbdf4 100644 --- a/test/merkle/merkle.cpp +++ b/test/merkle/merkle.cpp @@ -26,8 +26,7 @@ #include #include #include -//#include -//#include +#include #include #include @@ -60,7 +59,7 @@ template void testing_validate_template_random_data(std::size_t leaf_number) { std::array data_not_in_tree = {0}; auto data = generate_random_data(leaf_number); - auto tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()); + auto tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()).get(); std::size_t proof_idx = std::rand() % leaf_number; nil::crypto3::containers::merkle_proof proof(tree, proof_idx); @@ -75,7 +74,7 @@ void testing_validate_template_random_data(std::size_t leaf_number) { template void testing_validate_template(std::vector data) { std::array data_not_in_tree = {'\x6d', '\x65', '\x73', '\x73', '\x61', '\x67', '\x65'}; - nil::crypto3::containers::merkle_tree tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()); + nil::crypto3::containers::merkle_tree tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()).get(); nil::crypto3::containers::merkle_proof proof(tree, 0); bool good_validate = proof.validate(data[0]); bool wrong_leaf_validate = proof.validate(data[1]); @@ -87,7 +86,7 @@ void testing_validate_template(std::vector data) { template void testing_hash_template(std::vector data, std::string result) { - nil::crypto3::containers::merkle_tree tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()); + nil::crypto3::containers::merkle_tree tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()).get(); BOOST_CHECK(result == std::to_string(tree.root())); } @@ -124,7 +123,6 @@ ACTOR_THREAD_TEST_CASE(merkletree_validate_test_2) { // nil::crypto3::algebra::curves::forms::twisted_edwards>>; // std::size_t leaf_number = 8; // testing_validate_template_random_data(leaf_number); -// return make_ready_future<>(); //} ACTOR_THREAD_TEST_CASE(merkletree_hash_test_1) { From 7f47e29f17c057e374131b4ba3eac354c76911c8 Mon Sep 17 00:00:00 2001 From: Zerg1996 Date: Fri, 27 May 2022 16:07:03 +0200 Subject: [PATCH 07/23] Improve make_merkle_tree --- include/nil/actor/container/merkle/tree.hpp | 88 +++++++++++++-------- test/merkle/merkle.cpp | 34 +++----- 2 files changed, 68 insertions(+), 54 deletions(-) diff --git a/include/nil/actor/container/merkle/tree.hpp b/include/nil/actor/container/merkle/tree.hpp index b5cfd80f74..8a54f074ac 100644 --- a/include/nil/actor/container/merkle/tree.hpp +++ b/include/nil/actor/container/merkle/tree.hpp @@ -44,31 +44,60 @@ #include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + namespace nil { namespace actor { namespace containers { namespace detail { + template - nil::actor::future> - make_merkle_tree(LeafIterator first, LeafIterator last) { + nil::crypto3::containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, + LeafIterator last) { typedef T node_type; typedef typename node_type::hash_type hash_type; typedef typename node_type::value_type value_type; - nil::crypto3::containers::detail::merkle_tree_impl ret(std::distance(first, last)); - - ret.reserve(ret.complete_size()); - - while (first != last) { - ret.emplace_back(crypto3::hash(*first++)); + std::size_t number_leaves = std::distance(first, last); + nil::crypto3::containers::detail::merkle_tree_impl ret(number_leaves); + std::size_t core_count = nil::actor::smp::count; + ret.resize(ret.complete_size()); + + auto ret_p = make_foreign(&ret); + std::size_t parallels = std::min(core_count, number_leaves); + std::vector> fut; + for (auto i = 0; i < parallels; ++i) { + auto begin = i * (number_leaves / parallels); + auto end = (i + 1) * (number_leaves / parallels); + if (i == parallels - 1) { + end = number_leaves; + } + fut.emplace_back(nil::actor::smp::submit_to(i, [begin, end, first, p = ret_p.get()]() { + auto itr = first; + for (auto i = begin; i < end; ++i) { + (*p)[i] = (value_type)crypto3::hash(*itr++); + } + return nil::actor::make_ready_future<>(); + })); + first += number_leaves / parallels; } + nil::actor::when_all(fut.begin(), fut.end()).get(); std::size_t row_size = ret.leaves() / Arity; typename nil::crypto3::containers::detail::merkle_tree_impl::iterator it = ret.begin(); - + std::size_t current_pos = number_leaves; for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { - std::vector>> fut; - std::size_t parallels = std::min((std::size_t)nil::actor::smp::count, row_size); + fut.clear(); + parallels = std::min(core_count, row_size); std::size_t node_per_shard = row_size / parallels; for (std::size_t c = 0; c < parallels; ++c) { @@ -79,36 +108,33 @@ namespace nil { } auto it_c = it + node_per_shard * c * Arity; - fut.push_back(nil::actor::smp::submit_to(c, [begin_row, end_row, it_c] { - std::vector res; - for (size_t i = 0; i < end_row - begin_row; ++i) { - res.push_back(nil::crypto3::containers::detail::generate_hash( - it_c + i * Arity, it_c + (i + 1) * Arity)); - } - return nil::actor::make_ready_future>(res); - })); + fut.push_back( + nil::actor::smp::submit_to(c, [begin_row, end_row, it_c, current_pos, p = ret_p.get()] { + auto index_pos = current_pos; + for (size_t i = 0; i < end_row - begin_row; ++i, ++index_pos) { + (*p)[index_pos] = nil::crypto3::containers::detail::generate_hash( + it_c + i * Arity, it_c + (i + 1) * Arity); + } + return nil::actor::make_ready_future<>(); + })); + current_pos += end_row - begin_row; } it += Arity * row_size; - for (auto &i : fut) { - std::vector v = i.get(); - for (std::size_t j = 0; j < v.size(); ++j) { - ret.emplace_back(v[j]); - } - } + nil::actor::when_all(fut.begin(), fut.end()).get(); } - return nil::actor::make_ready_future>(ret); + return *ret_p; } } // namespace detail template - nil::actor::future> make_merkle_tree(LeafIterator first, - LeafIterator last) { - return detail::make_merkle_tree< + future> make_merkle_tree(LeafIterator first, LeafIterator last) { + return make_ready_future>(detail::make_merkle_tree< typename std::conditional::value, - nil::crypto3::containers::detail::merkle_tree_node, T>::type, - Arity>(first, last); + nil::crypto3::containers::detail::merkle_tree_node, + T>::type, + Arity>(first, last)); } } // namespace containers diff --git a/test/merkle/merkle.cpp b/test/merkle/merkle.cpp index 609ffcbdf4..e6c1beaeaa 100644 --- a/test/merkle/merkle.cpp +++ b/test/merkle/merkle.cpp @@ -30,8 +30,6 @@ #include #include -#include -#include #include #include @@ -41,6 +39,10 @@ #include #include +#include + +#include +#include template typename std::enable_if::value, std::vector>>::type @@ -116,25 +118,11 @@ ACTOR_THREAD_TEST_CASE(merkletree_validate_test_2) { testing_validate_template_random_data, 3, std::uint8_t, 1>(leaf_number); } -//ACTOR_THREAD_TEST_CASE(merkletree_validate_test_3) { -// using hash_type = nil::crypto3::hashes::pedersen< -// nil::crypto3::hashes::find_group_hash_default_params, nil::crypto3::hashes::sha2<256>, -// nil::crypto3::algebra::curves::jubjub::template g1_type>; -// std::size_t leaf_number = 8; -// testing_validate_template_random_data(leaf_number); -//} - -ACTOR_THREAD_TEST_CASE(merkletree_hash_test_1) { - std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}}; - testing_hash_template, 2>(v, "3b828c4f4b48c5d4cb5562a474ec9e2fd8d5546fae40e90732ef635892e42720"); - testing_hash_template(v, "11ee8b50825ce6f816a1ae06d4aa0045"); - testing_hash_template, 2>(v, "0ed2a2145cae554ca57f08420d6cb58629ca1e89dc92f819c6c1d13d"); -} - -ACTOR_THREAD_TEST_CASE(merkletree_hash_test_2) { - std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; - testing_hash_template, 3>(v, "6831d4d32538bedaa7a51970ac10474d5884701c840781f0a434e5b6868d4b73"); - testing_hash_template(v, "0733c4cd580b1523cfbb9751f42e9420"); - testing_hash_template, 3>(v, "d9d0ff26d10aaac2882c08eb2b55e78690c949d1a73b1cfc0eb322ee"); +ACTOR_THREAD_TEST_CASE(merkletree_validate_test_3) { + using hash_type = nil::crypto3::hashes::pedersen< + nil::crypto3::hashes::find_group_hash_default_params, nil::crypto3::hashes::sha2<256>, + nil::crypto3::algebra::curves::jubjub::template g1_type>; + std::size_t leaf_number = 8; + testing_validate_template_random_data(leaf_number); } \ No newline at end of file From 2898a37b9fddece74cef6fe8c01fc002ef570504 Mon Sep 17 00:00:00 2001 From: Zerg1996 Date: Sun, 10 Jul 2022 09:51:19 +0200 Subject: [PATCH 08/23] Remove unused headers --- include/nil/actor/container/merkle/tree.hpp | 10 ---------- test/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/include/nil/actor/container/merkle/tree.hpp b/include/nil/actor/container/merkle/tree.hpp index 8a54f074ac..8c4274881d 100644 --- a/include/nil/actor/container/merkle/tree.hpp +++ b/include/nil/actor/container/merkle/tree.hpp @@ -41,19 +41,9 @@ #include #include - -#include - -#include -#include -#include #include -#include -#include - #include #include -#include namespace nil { namespace actor { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f6bcab8a22..95de704bcd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -31,7 +31,7 @@ endif () function(actor_add_test name) get_filename_component(test_name ${name} NAME) - set(target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${test_name}_test) + string(REPLACE "/" "_" target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${test_name}_test) set(test_kinds ACTOR From efa66dcbb98cab920d2c105c6647146a01fe84ed Mon Sep 17 00:00:00 2001 From: Nick Volynkin Date: Tue, 30 May 2023 15:51:08 +0600 Subject: [PATCH 09/23] Use http paths for submodules Required for building proof-market-toolchain in CI. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 0267228a00..9373da4a58 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "cmake/modules"] path = cmake/modules - url = git@github.com:BoostCMake/cmake_modules.git \ No newline at end of file + url = https://github.com/NilFoundation/actor-containers.git From ae1dff29c4a622a8bb241adbf3946d791fd926b0 Mon Sep 17 00:00:00 2001 From: "e.tatuzova" Date: Tue, 14 Nov 2023 12:31:45 +0400 Subject: [PATCH 10/23] Poseidon support provided #2 --- include/nil/actor/container/merkle/tree.hpp | 80 ++++++++++++++++++++- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/include/nil/actor/container/merkle/tree.hpp b/include/nil/actor/container/merkle/tree.hpp index 8c4274881d..95c4fb438b 100644 --- a/include/nil/actor/container/merkle/tree.hpp +++ b/include/nil/actor/container/merkle/tree.hpp @@ -49,8 +49,7 @@ namespace nil { namespace actor { namespace containers { namespace detail { - - template + template::value, bool> = true> nil::crypto3::containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { typedef T node_type; @@ -116,6 +115,82 @@ namespace nil { } return *ret_p; } + + template< + typename T, std::size_t Arity, typename LeafIterator, + std::enable_if_t::value, bool> = true + > + nil::crypto3::containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, + LeafIterator last) { +// We can compare it with one-thread version with multi-thread +// nil::crypto3::containers::detail::make_merkle_tree(first, last); + + typedef T node_type; + typedef typename node_type::hash_type hash_type; + typedef typename node_type::value_type value_type; + + std::size_t number_leaves = std::distance(first, last); + nil::crypto3::containers::detail::merkle_tree_impl ret(number_leaves); + std::size_t core_count = nil::actor::smp::count; + ret.resize(ret.complete_size()); + + auto ret_p = make_foreign(&ret); + std::size_t parallels = std::min(core_count-1, number_leaves); + std::vector> fut; + for (auto i = 0; i < parallels; ++i) { + auto begin = i * (number_leaves / parallels); + auto end = (i + 1) * (number_leaves / parallels); + if (i == parallels - 1) { + end = number_leaves; + } + fut.emplace_back(nil::actor::smp::submit_to(i+1, [begin, end, first, p = ret_p.get()]() { + + auto itr = first; + for (auto i = begin; i < end; ++i) { + auto leaf = *itr; + (*p)[i] = (value_type)nil::crypto3::containers::detail::generate_poseidon_leaf_hash(leaf); + itr++; + } + return nil::actor::make_ready_future<>(); + })); + first += number_leaves / parallels; + } + nil::actor::when_all(fut.begin(), fut.end()).get(); + + std::size_t row_size = ret.leaves() / Arity; + typename nil::crypto3::containers::detail::merkle_tree_impl::iterator it = ret.begin(); + std::size_t current_pos = number_leaves; + for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { + fut.clear(); + parallels = std::min(core_count-1, row_size); + std::size_t node_per_shard = row_size / parallels; + + for (std::size_t c = 0; c < parallels; ++c) { + auto begin_row = node_per_shard * c; + auto end_row = node_per_shard * (c + 1); + if (c == parallels - 1) { + end_row = row_size; + } + auto it_c = it + node_per_shard * c * Arity; + + fut.push_back( + nil::actor::smp::submit_to(c+1, [begin_row, end_row, it_c, current_pos, p = ret_p.get()] { + auto index_pos = current_pos; + for (size_t i = 0; i < end_row - begin_row; ++i, ++index_pos) { + (*p)[index_pos] = nil::crypto3::containers::detail::generate_poseidon_hash( + *(it_c + i * Arity), *(it_c + i * Arity + 1)); + } + return nil::actor::make_ready_future<>(); + })); + current_pos += end_row - begin_row; + } + + it += Arity * row_size; + + nil::actor::when_all(fut.begin(), fut.end()).get(); + } + return *ret_p; + } } // namespace detail template @@ -126,7 +201,6 @@ namespace nil { T>::type, Arity>(first, last)); } - } // namespace containers } // namespace actor } // namespace nil From cae18d9141adc13263eda03b7c1288c46bc32bfb Mon Sep 17 00:00:00 2001 From: Martun Karapetyan Date: Thu, 21 Dec 2023 01:18:10 -0800 Subject: [PATCH 11/23] Remove a cast. --- include/nil/actor/container/merkle/tree.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nil/actor/container/merkle/tree.hpp b/include/nil/actor/container/merkle/tree.hpp index 95c4fb438b..e754ae3ca4 100644 --- a/include/nil/actor/container/merkle/tree.hpp +++ b/include/nil/actor/container/merkle/tree.hpp @@ -148,7 +148,7 @@ namespace nil { auto itr = first; for (auto i = begin; i < end; ++i) { auto leaf = *itr; - (*p)[i] = (value_type)nil::crypto3::containers::detail::generate_poseidon_leaf_hash(leaf); + (*p)[i] = nil::crypto3::containers::detail::generate_poseidon_leaf_hash(leaf); itr++; } return nil::actor::make_ready_future<>(); From a69f526757b4d84fc9b742cb2938614947744b3d Mon Sep 17 00:00:00 2001 From: Martun Karapetyan Date: Wed, 14 Feb 2024 12:28:09 +0400 Subject: [PATCH 12/23] Resetting to crypto3-containers. --- CMakeLists.txt | 19 +- README.md | 4 +- example/CMakeLists.txt | 20 +- example/merkle/merkle.cpp | 80 +-- include/nil/actor/container/merkle/tree.hpp | 208 ------ .../crypto3/container/accumulation_vector.hpp | 104 +++ include/nil/crypto3/container/merkle/node.hpp | 50 ++ .../nil/crypto3/container/merkle/proof.hpp | 336 ++++++++++ include/nil/crypto3/container/merkle/tree.hpp | 592 ++++++++++++++++++ .../nil/crypto3/container/sparse_vector.hpp | 298 +++++++++ test/CMakeLists.txt | 124 ++-- test/merkle/merkle.cpp | 331 ++++++++-- 12 files changed, 1734 insertions(+), 432 deletions(-) delete mode 100644 include/nil/actor/container/merkle/tree.hpp create mode 100644 include/nil/crypto3/container/accumulation_vector.hpp create mode 100644 include/nil/crypto3/container/merkle/node.hpp create mode 100644 include/nil/crypto3/container/merkle/proof.hpp create mode 100644 include/nil/crypto3/container/merkle/tree.hpp create mode 100644 include/nil/crypto3/container/sparse_vector.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 45c212c70d..753eff0125 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,14 +31,13 @@ cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0057 NEW) cmake_policy(SET CMP0079 OLD) -list(APPEND CMAKE_MODULE_PATH "cmake" - "cmake/modules/share/modules/cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/share/modules/cmake") -cm_find_package(CM) include(CMConfig) include(CMSetupVersion) -cm_workspace(actor) +cm_workspace(crypto3) macro(cm_find_package NAME) if (NOT "${NAME}" MATCHES "^${CMAKE_WORKSPACE_NAME}_.*$" AND NOT "${NAME}" STREQUAL CM) @@ -53,10 +52,10 @@ include(CMDeploy) include(CMSetupVersion) if (NOT Boost_FOUND AND NOT CMAKE_CROSSCOMPILING) - cm_find_package(Boost REQUIRED COMPONENTS filesystem) + cm_find_package(Boost COMPONENTS REQUIRED filesystem) endif () -cm_project(containers WORKSPACE_NAME ${CMAKE_WORKSPACE_NAME} LANGUAGES ASM C CXX) +cm_project(containers WORKSPACE_NAME ${CMAKE_WORKSPACE_NAME}) option(BUILD_DOXYGEN_DOCS "Build with configuring Doxygen documentation compiler" TRUE) @@ -82,13 +81,9 @@ set_target_properties(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} PROPERTIES EXPORT_NAME ${CURRENT_PROJECT_NAME}) target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE - ${CMAKE_WORKSPACE_NAME}::network - ${CMAKE_WORKSPACE_NAME}::core -# epoll-shim - crypto3::algebra - crypto3::hash - crypto3::containers + ${CMAKE_WORKSPACE_NAME}::algebra + ${CMAKE_WORKSPACE_NAME}::hash ${Boost_LIBRARIES}) diff --git a/README.md b/README.md index 18b3bc1752..ddccd889e1 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,7 @@ To actually include this library in a project it is required to: ### Internal -* [Boost.Predef](https://github.com/nilfoundation/predef.git) (until https://github.com/boostorg/predef/pull/108 and https://github.com/boostorg/predef/pull/107 are accepted) -* [Boost.Config](https://github.com/nilfoundation/config.git) (until https://github.com/boostorg/config/pull/338 and https://github.com/boostorg/config/pull/339 are accepted) * [Hash](https://github.com/nilfoundation/crypto3-hash.git). ### External -* [Boost](https://boost.org) (>= 1.58) \ No newline at end of file +* [Boost](https://boost.org) (>= 1.76) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 05f3cd7ebd..346575486f 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -2,7 +2,6 @@ # MIT License # # Copyright (c) 2020 Mikhail Komarov -# Copyright (c) 2022 Aleksei Moskvin # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,7 +23,7 @@ #---------------------------------------------------------------------------// -include_directories("../include" +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include" "${CMAKE_CURRENT_BINARY_DIR}/include" ${Boost_INCLUDE_DIRS}) @@ -35,22 +34,15 @@ macro(define_containers_example example) add_executable(${target_name} ${example}.cpp) target_link_libraries(${target_name} PRIVATE - ${CMAKE_WORKSPACE_NAME}::core - ${CMAKE_WORKSPACE_NAME}::network - ${CMAKE_WORKSPACE_NAME}::containers - epoll-shim - - crypto3::algebra - crypto3::hash - crypto3::containers - + ${CMAKE_WORKSPACE_NAME}::algebra + ${CMAKE_WORKSPACE_NAME}::hash ${Boost_LIBRARIES}) set_target_properties(${target_name} PROPERTIES CXX_STANDARD 17) endmacro() set(EXAMPLES_NAMES - "merkle/merkle") + "merkle/merkle") -foreach (EXAMPLE_NAME ${EXAMPLES_NAMES}) +foreach(EXAMPLE_NAME ${EXAMPLES_NAMES}) define_containers_example(${EXAMPLE_NAME}) -endforeach () +endforeach() diff --git a/example/merkle/merkle.cpp b/example/merkle/merkle.cpp index 682ca94f8e..cc7e60037c 100644 --- a/example/merkle/merkle.cpp +++ b/example/merkle/merkle.cpp @@ -22,62 +22,46 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. //---------------------------------------------------------------------------// + +#include +#include #include #include #include -#include -#include -#include -#include - -#include - using namespace nil::crypto3; using namespace nil::crypto3::containers; -int main(int argc, char **argv) { - nil::actor::app_template app; - app.run(argc, argv, [] { - return nil::actor::async([] { - std::vector> data_on_leafs = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, - {'5'}, {'6'}, {'7'}, {'8'}}; - std::array element_not_in_tree = {'9'}; - nil::crypto3::containers::merkle_tree, 3> tree = - nil::actor::containers::make_merkle_tree, 3>(data_on_leafs.begin(), - data_on_leafs.end()).get(); - - nil::crypto3::containers::merkle_proof, 3> proof_leaf_3(tree, 3); - nil::crypto3::containers::merkle_proof, 3> proof_leaf_0(tree, 0); - - std::vector> data_to_check = { - {data_on_leafs[2]}, {data_on_leafs[0]}, {data_on_leafs[3]}, element_not_in_tree}; - for (size_t i = 0; i < data_to_check.size(); ++i) { - std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 0: "; - std::cout << std::boolalpha << proof_leaf_0.validate(data_to_check[i]) << std::endl; - std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 3: "; - std::cout << std::boolalpha << proof_leaf_3.validate(data_to_check[i]) << std::endl; - } +int main() { + std::vector > data_on_leafs = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; + std::array element_not_in_tree = {'9'}; + merkle_tree, 3> tree = make_merkle_tree, 3>(data_on_leafs.begin(), data_on_leafs.end()); + merkle_proof, 3> proof_leaf_3(tree, 3); + merkle_proof, 3> proof_leaf_0(tree, 0); +// std::cout << "Tree structure:" << std::endl; +// std::cout << tree << std::endl; + std::vector> data_to_check = {{data_on_leafs[2]}, {data_on_leafs[0]}, element_not_in_tree}; + for (size_t i = 0; i < data_to_check.size(); ++i) { + std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 0: "; + std::cout << std::boolalpha << proof_leaf_0.validate(data_to_check[i]) << std::endl; + std::cout << "Is leaf " << data_to_check[i][0] << " was in tree in position 3: "; + std::cout << std::boolalpha << proof_leaf_3.validate(data_to_check[i]) << std::endl; + } + std::cout << std::endl; - std::array left = {'\x6d', '\x65', '\x73', '\x73', '\x61', '\x67', '\x65'}; - std::array right = {'\x20', '\x64', '\x69', '\x67', '\x65', '\x73', '\x74'}; - std::vector> simple_binary_tree_data = {left, right}; - nil::crypto3::containers::merkle_tree, 2> simple_binary_tree = - nil::actor::containers::make_merkle_tree, 2>(simple_binary_tree_data.begin(), - simple_binary_tree_data.end()).get(); - nil::crypto3::containers::merkle_proof, 2> simple_binary_proof_leaf_1( - simple_binary_tree, 1); - // std::cout << "Tree simple binary structure:" << std::endl; - // std::cout << simple_binary_tree << std::endl; - std::cout << "Is leaf " << data_on_leafs[1][0] << " was in tree in position 1: "; - std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(data_on_leafs[1]) << std::endl; - std::cout << "Is leaf left was in tree in position 1: "; - std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(left) << std::endl; - std::cout << "Is leaf right was in tree in position 1: "; - std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(right) << std::endl; + std::array left = {'\x6d', '\x65', '\x73', '\x73', '\x61', '\x67', '\x65'}; + std::array right = {'\x20', '\x64', '\x69', '\x67', '\x65', '\x73', '\x74'}; + std::vector > simple_binary_tree_data = {left, right}; + merkle_tree, 2> simple_binary_tree = make_merkle_tree, 2>(simple_binary_tree_data.begin(), simple_binary_tree_data.end()); + merkle_proof, 2> simple_binary_proof_leaf_1(simple_binary_tree, 1); +// std::cout << "Tree simple binary structure:" << std::endl; +// std::cout << simple_binary_tree << std::endl; + std::cout << "Is leaf " << data_on_leafs[1][0] << " was in tree in position 1: "; + std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(data_on_leafs[1]) << std::endl; + std::cout << "Is leaf left was in tree in position 1: "; + std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(left) << std::endl; + std::cout << "Is leaf right was in tree in position 1: "; + std::cout << std::boolalpha << simple_binary_proof_leaf_1.validate(right) << std::endl; - return 0; - }); - }); } \ No newline at end of file diff --git a/include/nil/actor/container/merkle/tree.hpp b/include/nil/actor/container/merkle/tree.hpp deleted file mode 100644 index e754ae3ca4..0000000000 --- a/include/nil/actor/container/merkle/tree.hpp +++ /dev/null @@ -1,208 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2018-2020 Mikhail Komarov -// Copyright (c) 2021-2022 Aleksei Moskvin -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef ACTOR_MERKLE_TREE_HPP -#define ACTOR_MERKLE_TREE_HPP - -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -namespace nil { - namespace actor { - namespace containers { - namespace detail { - template::value, bool> = true> - nil::crypto3::containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, - LeafIterator last) { - typedef T node_type; - typedef typename node_type::hash_type hash_type; - typedef typename node_type::value_type value_type; - - std::size_t number_leaves = std::distance(first, last); - nil::crypto3::containers::detail::merkle_tree_impl ret(number_leaves); - std::size_t core_count = nil::actor::smp::count; - ret.resize(ret.complete_size()); - - auto ret_p = make_foreign(&ret); - std::size_t parallels = std::min(core_count, number_leaves); - std::vector> fut; - for (auto i = 0; i < parallels; ++i) { - auto begin = i * (number_leaves / parallels); - auto end = (i + 1) * (number_leaves / parallels); - if (i == parallels - 1) { - end = number_leaves; - } - fut.emplace_back(nil::actor::smp::submit_to(i, [begin, end, first, p = ret_p.get()]() { - auto itr = first; - for (auto i = begin; i < end; ++i) { - (*p)[i] = (value_type)crypto3::hash(*itr++); - } - return nil::actor::make_ready_future<>(); - })); - first += number_leaves / parallels; - } - nil::actor::when_all(fut.begin(), fut.end()).get(); - - std::size_t row_size = ret.leaves() / Arity; - typename nil::crypto3::containers::detail::merkle_tree_impl::iterator it = ret.begin(); - std::size_t current_pos = number_leaves; - for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { - fut.clear(); - parallels = std::min(core_count, row_size); - std::size_t node_per_shard = row_size / parallels; - - for (std::size_t c = 0; c < parallels; ++c) { - auto begin_row = node_per_shard * c; - auto end_row = node_per_shard * (c + 1); - if (c == parallels - 1) { - end_row = row_size; - } - auto it_c = it + node_per_shard * c * Arity; - - fut.push_back( - nil::actor::smp::submit_to(c, [begin_row, end_row, it_c, current_pos, p = ret_p.get()] { - auto index_pos = current_pos; - for (size_t i = 0; i < end_row - begin_row; ++i, ++index_pos) { - (*p)[index_pos] = nil::crypto3::containers::detail::generate_hash( - it_c + i * Arity, it_c + (i + 1) * Arity); - } - return nil::actor::make_ready_future<>(); - })); - current_pos += end_row - begin_row; - } - - it += Arity * row_size; - - nil::actor::when_all(fut.begin(), fut.end()).get(); - } - return *ret_p; - } - - template< - typename T, std::size_t Arity, typename LeafIterator, - std::enable_if_t::value, bool> = true - > - nil::crypto3::containers::detail::merkle_tree_impl make_merkle_tree(LeafIterator first, - LeafIterator last) { -// We can compare it with one-thread version with multi-thread -// nil::crypto3::containers::detail::make_merkle_tree(first, last); - - typedef T node_type; - typedef typename node_type::hash_type hash_type; - typedef typename node_type::value_type value_type; - - std::size_t number_leaves = std::distance(first, last); - nil::crypto3::containers::detail::merkle_tree_impl ret(number_leaves); - std::size_t core_count = nil::actor::smp::count; - ret.resize(ret.complete_size()); - - auto ret_p = make_foreign(&ret); - std::size_t parallels = std::min(core_count-1, number_leaves); - std::vector> fut; - for (auto i = 0; i < parallels; ++i) { - auto begin = i * (number_leaves / parallels); - auto end = (i + 1) * (number_leaves / parallels); - if (i == parallels - 1) { - end = number_leaves; - } - fut.emplace_back(nil::actor::smp::submit_to(i+1, [begin, end, first, p = ret_p.get()]() { - - auto itr = first; - for (auto i = begin; i < end; ++i) { - auto leaf = *itr; - (*p)[i] = nil::crypto3::containers::detail::generate_poseidon_leaf_hash(leaf); - itr++; - } - return nil::actor::make_ready_future<>(); - })); - first += number_leaves / parallels; - } - nil::actor::when_all(fut.begin(), fut.end()).get(); - - std::size_t row_size = ret.leaves() / Arity; - typename nil::crypto3::containers::detail::merkle_tree_impl::iterator it = ret.begin(); - std::size_t current_pos = number_leaves; - for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { - fut.clear(); - parallels = std::min(core_count-1, row_size); - std::size_t node_per_shard = row_size / parallels; - - for (std::size_t c = 0; c < parallels; ++c) { - auto begin_row = node_per_shard * c; - auto end_row = node_per_shard * (c + 1); - if (c == parallels - 1) { - end_row = row_size; - } - auto it_c = it + node_per_shard * c * Arity; - - fut.push_back( - nil::actor::smp::submit_to(c+1, [begin_row, end_row, it_c, current_pos, p = ret_p.get()] { - auto index_pos = current_pos; - for (size_t i = 0; i < end_row - begin_row; ++i, ++index_pos) { - (*p)[index_pos] = nil::crypto3::containers::detail::generate_poseidon_hash( - *(it_c + i * Arity), *(it_c + i * Arity + 1)); - } - return nil::actor::make_ready_future<>(); - })); - current_pos += end_row - begin_row; - } - - it += Arity * row_size; - - nil::actor::when_all(fut.begin(), fut.end()).get(); - } - return *ret_p; - } - } // namespace detail - - template - future> make_merkle_tree(LeafIterator first, LeafIterator last) { - return make_ready_future>(detail::make_merkle_tree< - typename std::conditional::value, - nil::crypto3::containers::detail::merkle_tree_node, - T>::type, - Arity>(first, last)); - } - } // namespace containers - } // namespace actor -} // namespace nil - -#endif // ACTOR_MERKLE_TREE_HPP diff --git a/include/nil/crypto3/container/accumulation_vector.hpp b/include/nil/crypto3/container/accumulation_vector.hpp new file mode 100644 index 0000000000..f2d4832049 --- /dev/null +++ b/include/nil/crypto3/container/accumulation_vector.hpp @@ -0,0 +1,104 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2021 Mikhail Komarov +// Copyright (c) 2020-2021 Nikita Kaskov +// Copyright (c) 2021 Ilias Khairullin +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_ZK_SNARK_ACCUMULATION_VECTOR_HPP +#define CRYPTO3_ZK_SNARK_ACCUMULATION_VECTOR_HPP + +#include +#include + +#include + +namespace nil { + namespace crypto3 { + namespace container { + + /** + * An accumulation vector comprises an accumulation value and a sparse vector. + * The method "accumulate_chunk" allows one to accumulate portions of the sparse + * vector into the accumulation value. + */ + template + class accumulation_vector { + using underlying_value_type = typename Type::value_type; + + public: + using group_type = Type; + + underlying_value_type first; + sparse_vector rest; + + accumulation_vector() = default; + accumulation_vector(const accumulation_vector &other) = default; + accumulation_vector(accumulation_vector &&other) = default; + accumulation_vector(const underlying_value_type &first, sparse_vector &&rest) : + first(first), rest(std::move(rest)) {}; + accumulation_vector(underlying_value_type &&first, sparse_vector &&rest) : + first(std::move(first)), rest(std::move(rest)) {}; + accumulation_vector(underlying_value_type &&first, std::vector &&v) : + first(std::move(first)), rest(std::move(v)) { + } + accumulation_vector(std::vector &&v) : + first(underlying_value_type::zero()), rest(std::move(v)) {}; + + accumulation_vector &operator=(const accumulation_vector &other) = default; + accumulation_vector &operator=(accumulation_vector &&other) = default; + + bool operator==(const accumulation_vector &other) const { + return (this->first == other.first && this->rest == other.rest); + } + + bool is_fully_accumulated() const { + return rest.empty(); + } + + std::size_t domain_size() const { + return rest.domain_size(); + } + + std::size_t size() const { + return rest.domain_size(); + } + + std::size_t size_in_bits() const { + const std::size_t first_size_in_bits = Type::value_bits; + const std::size_t rest_size_in_bits = rest.size_in_bits(); + return first_size_in_bits + rest_size_in_bits; + } + + template + accumulation_vector accumulate_chunk(InputIterator begin, InputIterator end, + std::size_t offset) const { + std::pair> acc_result = rest.insert(offset, begin, end); + underlying_value_type new_first = first + acc_result.first; + return accumulation_vector(std::move(new_first), std::move(acc_result.second)); + } + }; + } // namespace container + } // namespace crypto3 +} // namespace nil + +#endif // CRYPTO3_ZK_SNARK_ACCUMULATION_VECTOR_HPP diff --git a/include/nil/crypto3/container/merkle/node.hpp b/include/nil/crypto3/container/merkle/node.hpp new file mode 100644 index 0000000000..66940c9f7b --- /dev/null +++ b/include/nil/crypto3/container/merkle/node.hpp @@ -0,0 +1,50 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2020 Mikhail Komarov +// Copyright (c) 2021 Aleksei Moskvin +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_MERKLE_TREE_NODE_HPP +#define CRYPTO3_MERKLE_TREE_NODE_HPP + +#include + +namespace nil { + namespace crypto3 { + namespace containers { + namespace detail { + template + struct merkle_tree_node { + typedef Hash hash_type; + + constexpr static const std::size_t digest_bits = hash_type::digest_bits; + typedef typename hash_type::digest_type digest_type; + + typedef typename Hash::digest_type value_type; + constexpr static const std::size_t value_bits = digest_bits; + }; + } // namespace detail + } // namespace containers + } // namespace crypto3 +} // namespace nil + +#endif // CRYPTO3_NODE_HPP diff --git a/include/nil/crypto3/container/merkle/proof.hpp b/include/nil/crypto3/container/merkle/proof.hpp new file mode 100644 index 0000000000..6cae846bec --- /dev/null +++ b/include/nil/crypto3/container/merkle/proof.hpp @@ -0,0 +1,336 @@ +//---------------------------------------------------------------------------// +// MIT License +// +// Copyright (c) 2020-2021 Mikhail Komarov +// Copyright (c) 2020-2021 Nikita Kaskov +// Copyright (c) 2021-2022 Aleksei Moskvin +// Copyright (c) 2021 Ilias Khairullin +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_MERKLE_PROOF_HPP +#define CRYPTO3_MERKLE_PROOF_HPP + +#include +#include +#include + +#include + +#include +#include + +namespace nil { + namespace crypto3 { + namespace zk { + namespace components { + template + class merkle_proof; + } // namespace components + } // namespace zk + namespace marshalling { + namespace types { + template + class merkle_proof_marshalling; + } + } // namespace marshalling + namespace containers { + namespace detail { + template + class merkle_proof_impl { + public: + typedef NodeType node_type; + typedef typename node_type::hash_type hash_type; + + constexpr static const std::size_t arity = Arity; + + constexpr static const std::size_t value_bits = node_type::value_bits; + typedef typename node_type::value_type value_type; + + struct path_element_type { + path_element_type(value_type x, size_t pos) : _hash(x), _position(pos) { + } + path_element_type() { + } + + bool operator==(const path_element_type &rhs) const { + return _hash == rhs._hash && _position == rhs._position; + } + bool operator!=(const path_element_type &rhs) const { + return !(rhs == *this); + } + + const value_type &hash() const { + return _hash; + } + + std::size_t position() const { + return _position; + } + + value_type _hash; + std::size_t _position; + + template + friend class nil::crypto3::marshalling::types::merkle_proof_marshalling; + }; + + typedef std::array layer_type; + typedef std::vector path_type; + + merkle_proof_impl() : _li(0), _root(value_type()) {}; + + merkle_proof_impl(std::size_t li, value_type root, path_type path) : _li(li), _root(root), + _path(path){}; + + merkle_proof_impl(const merkle_tree &tree, const std::size_t leaf_idx) { + _root = tree.root(); + _path.resize(tree.row_count() - 1); + _li = leaf_idx; + + typename std::vector::iterator v_itr = _path.begin(); + std::size_t cur_leaf = leaf_idx; + std::size_t row_len = tree.leaves(); + std::size_t row_begin_idx = 0; + while (cur_leaf != tree.size() - 1) { // while it's not _root + std::size_t cur_leaf_pos = cur_leaf % arity; + std::size_t cur_leaf_arity_pos = (cur_leaf - row_begin_idx) / arity; + std::size_t begin_this_arity = cur_leaf - cur_leaf_pos; + typename layer_type::iterator a_itr = v_itr->begin(); + for (size_t i = 0; i < cur_leaf_pos; ++i, ++begin_this_arity, ++a_itr) { + *a_itr = path_element_type(tree[begin_this_arity], i); + } + for (size_t i = cur_leaf_pos + 1; i < arity; ++i, ++begin_this_arity, ++a_itr) { + *a_itr = path_element_type(tree[begin_this_arity + 1], i); + } + v_itr++; + cur_leaf = row_len + row_begin_idx + cur_leaf_arity_pos; + row_begin_idx += row_len; + row_len /= arity; + } + } + + // Specilized implementaions below. + template + typename std::enable_if_t::value, + bool> validate(const Hashable &a) const { + using hash_type = typename NodeType::hash_type; + value_type d = crypto3::hash(a); + for (auto &it : _path) { + accumulator_set acc; + size_t i = 0; + for (; (i < arity - 1) && i == it[i]._position; ++i) { + crypto3::hash(it[i]._hash.begin(), it[i]._hash.end(), acc); + } + crypto3::hash(d.begin(), d.end(), acc); + for (; i < arity - 1; ++i) { + crypto3::hash(it[i]._hash.begin(), it[i]._hash.end(), acc); + } + d = accumulators::extract::hash(acc); + } + return (d == _root); + } + + // Specialize for poseidon. + template + typename std::enable_if_t::value, bool> + validate(const Hashable &a) const { + BOOST_ASSERT_MSG(Arity == 2, "Poseidon is only supported for arity 2"); + + typedef NodeType node_type; + typedef typename node_type::hash_type hash_type; + + constexpr static const std::size_t arity = Arity; + + typedef typename node_type::value_type value_type; + + value_type d = generate_poseidon_leaf_hash(a);// crypto3::hash(a); + for (auto &it : _path) { + std::vector values; + size_t i = 0; + for (; (i < arity - 1) && i == it[i]._position; ++i) { + values.push_back(it[i]._hash); + } + values.push_back(d); + for (; i < arity - 1; ++i) { + values.push_back(it[i]._hash); + } + d = generate_poseidon_hash(values[0], values[1]); + } + return (d == _root); + } + + static std::vector + generate_compressed_proofs(const containers::merkle_tree &tree, + std::vector leaf_idxs) { + assert(leaf_idxs.size() > 0); + std::vector sorted_idx(leaf_idxs.size()); + std::iota(sorted_idx.begin(), sorted_idx.end(), 0); + std::sort(sorted_idx.begin(), sorted_idx.end(), [&leaf_idxs](std::size_t i, std::size_t j) { + return leaf_idxs[i] < leaf_idxs[j]; }); + std::vector result_proofs(leaf_idxs.size()); + std::size_t row_len = tree.leaves(); + std::vector known(2 * row_len, false); + std::size_t prev_leaf_idx = leaf_idxs[sorted_idx[0]] + 1; + for (auto idx : sorted_idx) { + auto leaf_idx = leaf_idxs[idx]; + if (leaf_idx == prev_leaf_idx) { + result_proofs[idx] = merkle_proof_impl(leaf_idx, tree.root(), path_type()); + assert(result_proofs[idx].path().size() == 0); + continue; + } + path_type path(tree.row_count() - 1); + typename path_type::iterator path_itr = path.begin(); + std::size_t cur_leaf = leaf_idx; + std::size_t row_len = tree.leaves(); + std::size_t row_begin_idx = 0; + bool finish_path = false; + while (cur_leaf != tree.size() - 1) { + std::size_t cur_leaf_pos = cur_leaf % Arity; + std::size_t cur_leaf_arity_pos = (cur_leaf - row_begin_idx) / Arity; + std::size_t begin_this_arity = cur_leaf - cur_leaf_pos; + typename layer_type::iterator layer_itr = path_itr->begin(); + for (size_t i = 0; i < cur_leaf_pos; ++i, ++begin_this_arity) { + if (!known[begin_this_arity]) { + known[begin_this_arity] = true; + } else { + finish_path = true; + } + *layer_itr = path_element_type(tree[begin_this_arity], i); + ++layer_itr; + } + for (size_t i = cur_leaf_pos + 1; i < Arity; ++i, ++begin_this_arity) { + if (!known[begin_this_arity + 1]) { + known[begin_this_arity + 1] = true; + } else { + finish_path = true; + } + *layer_itr = path_element_type(tree[begin_this_arity + 1], i); + ++layer_itr; + } + path_itr++; + if (finish_path) { + break; + } + cur_leaf = row_len + row_begin_idx + cur_leaf_arity_pos; + row_begin_idx += row_len; + row_len /= Arity; + } + path.resize(path_itr - path.begin()); + result_proofs[idx] = merkle_proof_impl(leaf_idx, tree.root(), path); + prev_leaf_idx = leaf_idx; + } + return result_proofs; + } + + template + static bool validate_compressed_proofs(const std::vector &proofs, + const std::vector &a) { + assert(proofs.size() == a.size()); + assert(proofs.size() > 0); + std::vector sorted_idx(proofs.size()); + std::iota(sorted_idx.begin(), sorted_idx.end(), 0); + std::sort(sorted_idx.begin(), sorted_idx.end(), [&proofs](std::size_t i, std::size_t j) { + return proofs[i].leaf_index() >= proofs[j].leaf_index(); }); + std::stack> st; + auto root = proofs[sorted_idx.back()].root(); + auto full_proof_size = proofs[sorted_idx.back()].path().size(); + for (auto idx : sorted_idx) { + auto path = proofs[idx].path(); + value_type d = crypto3::hash(a[idx]); + std::vector hashes = {d}; + for (auto &it : path) { + accumulator_set acc; + std::size_t i = 0; + for (; (i < Arity - 1) && i == it[i].position(); ++i) { + crypto3::hash(it[i].hash().begin(), it[i].hash().end(), acc); + } + crypto3::hash(d.begin(), d.end(), acc); + for (; i < Arity - 1; ++i) { + crypto3::hash(it[i].hash().begin(), it[i].hash().end(), acc); + } + d = accumulators::extract::hash(acc); + hashes.push_back(d); + } + while (!st.empty()) { + auto top = st.top(); + if (top.second >= hashes.size()) { + break; + } + if (hashes[top.second] == top.first) { + st.pop(); + } else { + return false; + } + } + if (path.size() < full_proof_size) { + st.push(std::make_pair(d, path.size())); + } else if (d != root) { + return false; + } + } + return true; + } + + std::size_t leaf_index() const { + return _li; + } + + bool operator==(const merkle_proof_impl &rhs) const { + return _li == rhs._li && _root == rhs._root && _path == rhs._path; + } + bool operator!=(const merkle_proof_impl &rhs) const { + return !(rhs == *this); + } + + const value_type &root() const { + return _root; + } + + const path_type &path() const { + return _path; + } + + private: + std::size_t _li; + value_type _root; + path_type _path; + + template + friend class nil::crypto3::zk::components::merkle_proof; + + template + friend class nil::crypto3::marshalling::types::merkle_proof_marshalling; + }; + + + } // namespace detail + + template + using merkle_proof = + typename std::conditional::value, + detail::merkle_proof_impl, Arity>, + detail::merkle_proof_impl>::type; + + } // namespace containers + } // namespace crypto3 +} // namespace nil + +#endif diff --git a/include/nil/crypto3/container/merkle/tree.hpp b/include/nil/crypto3/container/merkle/tree.hpp new file mode 100644 index 0000000000..0b86d9c9cd --- /dev/null +++ b/include/nil/crypto3/container/merkle/tree.hpp @@ -0,0 +1,592 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2020 Mikhail Komarov +// Copyright (c) 2021-2022 Aleksei Moskvin +// Copyright (c) 2021 Ilias Khairullin +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_MERKLE_TREE_HPP +#define CRYPTO3_MERKLE_TREE_HPP + +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace nil { + namespace crypto3 { + namespace containers { + namespace detail { + // returns next highest power of two from a given number if it is not + // already a power of two. + inline size_t next_pow2(size_t n) { + return std::pow(2, std::ceil(std::log(n))); + } + + // find power of 2 of a number which is power of 2 + inline size_t log2_pow2(size_t n) { + return next_pow2(n); + } + + // Row_Count calculation given the number of _leaves in the tree and the branches. + inline size_t merkle_tree_row_count(size_t leafs, size_t branches) { + // Optimization + if (branches == 2) { + return std::log2(leafs) + 1; + } else { + return round(std::log(leafs) / std::log(branches)) + 1; + } + } + + // Tree length calculation given the number of _leaves in the tree and the branches. + inline size_t merkle_tree_length(size_t leafs, size_t branches) { + // Optimization + size_t len = leafs; + if (branches == 2) { + len = 2 * leafs - 1; + } else { + size_t cur = leafs; + while (cur != 0) { + cur /= branches; + len += cur; + } + } + return len; + } + + // This method returns the number of '_leaves' given a merkle tree + // length of 'len', where _leaves must be a power of 2, respecting the + // number of branches. + inline size_t merkle_tree_leaves(size_t tree_s, size_t branches) { + // Optimization + size_t len = tree_s; + if (branches == 2) { + len = (tree_s + 1) >> 1; + } else { + size_t cur = 1; + while (cur < len) { + len -= cur; + cur *= branches; + } + } + return len; + } + + // Tree length calculation given the number of _leaves in the tree, the + // rows_to_discard, and the branches. + inline size_t merkle_tree_cache_size(size_t leafs, size_t branches, size_t rows_to_discard) { + size_t shift = log2_pow2(branches); + size_t len = merkle_tree_length(leafs, branches); + size_t row_count = merkle_tree_row_count(leafs, branches); + + // '_rc - 1' means that we start discarding rows above the base + // layer, which is included in the current _rc. + size_t cache_base = row_count - 1 - rows_to_discard; + + size_t cache_size = len; + size_t cur_leafs = leafs; + + while (row_count > cache_base) { + cache_size -= cur_leafs; + cur_leafs >>= shift; // cur /= branches + row_count -= 1; + } + + return cache_size; + } + + inline bool is_merkle_tree_size_valid(size_t leafs, size_t branches) { + if (branches == 0 || leafs != next_pow2(leafs) || branches != next_pow2(branches)) { + return false; + } + + size_t cur = leafs; + size_t shift = log2_pow2(branches); + while (cur != 1) { + cur >>= shift; // cur /= branches + if (cur > leafs || cur == 0) { + return false; + } + } + + return true; + } + + // Given a tree of '_rc' with the specified number of 'branches', + // calculate the length of _hashes required for the proof. + inline size_t merkle_proof_lemma_length(size_t row_count, size_t branches) { + return 2 + ((branches - 1) * (row_count - 1)); + } + + // Merkle Tree. + // + // All _leaves and nodes are stored in a BGL graph structure. + // + // A merkle tree is a tree in which every non-leaf node is the hash of its + // child nodes. A diagram for merkle_tree_impl arity = 2: + // + // root = h1234 = h(h12 + h34) + // ./ \. + // h12 = h(h1 + h2) h34 = h(h3 + h4) + // ./ \. ./ \. + // h1 = h(tx1) h2 = h(tx2) h3 = h(tx3) h4 = h(tx4) + // ``` + // + // In graph representation: + // + // ```text + // root -> h12, h34 + // h12 -> h1, h2 + // h34 -> h3, h4 + // ``` + // + // Merkle root is always the top element. + template + struct merkle_tree_impl { + typedef NodeType node_type; + + typedef typename node_type::hash_type hash_type; + + typedef typename node_type::value_type value_type; + constexpr static const std::size_t value_bits = node_type::value_bits; + + typedef std::vector container_type; + + typedef typename container_type::allocator_type allocator_type; + typedef typename container_type::reference reference; + typedef typename container_type::const_reference const_reference; + typedef typename container_type::size_type size_type; + typedef typename container_type::difference_type difference_type; + typedef typename container_type::pointer pointer; + typedef typename container_type::const_pointer const_pointer; + typedef typename container_type::iterator iterator; + typedef typename container_type::const_iterator const_iterator; + typedef typename container_type::reverse_iterator reverse_iterator; + typedef typename container_type::const_reverse_iterator const_reverse_iterator; + + merkle_tree_impl() : _size(0), _leaves(0), _rc(0) {}; + + ~merkle_tree_impl() = default; + + merkle_tree_impl(size_t n) : + _size(detail::merkle_tree_length(n, Arity)), _leaves(n), + _rc(detail::merkle_tree_row_count(n, Arity)) { + BOOST_ASSERT_MSG(pow(Arity, round(std::log(n) / std::log(Arity))) == n, + "Wrong leaves number, it must be a power of Arity."); + } + + merkle_tree_impl(const merkle_tree_impl &x) : + _hashes(x._hashes), _size(x._size), _leaves(x._leaves), _rc(x._rc) { + } + + merkle_tree_impl(const merkle_tree_impl &x, const allocator_type &a) : _hashes(x.hashes(), a), + _size(x._size), + _leaves(x._leaves), + _rc(x._rc) {} + + merkle_tree_impl(const std::initializer_list &il) : _hashes(il) { + set_leaves(detail::merkle_tree_leaves(std::distance(il.begin(), il.end()), Arity)); + set_row_count(detail::merkle_tree_row_count(_leaves, Arity)); + set_complete_size(detail::merkle_tree_length(_leaves, Arity)); + } + + template::value, bool>::type = true> + merkle_tree_impl(Iterator first, Iterator last) : _hashes(first, last) { + set_leaves(detail::merkle_tree_leaves(std::distance(first, last), Arity)); + set_row_count(detail::merkle_tree_row_count(_leaves, Arity)); + set_complete_size(detail::merkle_tree_length(_leaves, Arity)); + } + + merkle_tree_impl(const std::initializer_list &il, const allocator_type &a) : _hashes(il, a) { + set_leaves(detail::merkle_tree_leaves(std::distance(il.begin(), il.end()), Arity)); + set_row_count(detail::merkle_tree_row_count(_leaves, Arity)); + set_complete_size(detail::merkle_tree_length(_leaves, Arity)); + } + + merkle_tree_impl(merkle_tree_impl &&x) + BOOST_NOEXCEPT(std::is_nothrow_move_constructible::value): + _hashes(x._hashes), + _size(x._size), _leaves(x._leaves), _rc(x._rc) { + } + + merkle_tree_impl(merkle_tree_impl &&x, const allocator_type &a) : + _hashes(x.hashes(), a), _size(x._size), _leaves(x._leaves), _rc(x._rc) { + } + + merkle_tree_impl &operator=(const merkle_tree_impl &x) { + _hashes = x.hashes(); + return *this; + } + + merkle_tree_impl &operator=(merkle_tree_impl &&x) { + _hashes = x._hashes; + _size = x._size; + _leaves = x._leaves; + _rc = x._rc; + return *this; + } + + bool operator==(const merkle_tree_impl &rhs) const { + return _hashes == rhs.val; + } + + bool operator!=(const merkle_tree_impl &rhs) const { + return !(rhs == *this); + } + + allocator_type get_allocator() const BOOST_NOEXCEPT { + return this->val.__alloc(); + } + + iterator begin() BOOST_NOEXCEPT { + return _hashes.begin(); + } + + const_iterator begin() const BOOST_NOEXCEPT { + return _hashes.begin(); + } + + iterator end() BOOST_NOEXCEPT { + return _hashes.end(); + } + + const_iterator end() const BOOST_NOEXCEPT { + return _hashes.end(); + } + + reverse_iterator rbegin() BOOST_NOEXCEPT { + return _hashes.rbegin(); + } + + const_reverse_iterator rbegin() const BOOST_NOEXCEPT { + return _hashes.rbegin(); + } + + reverse_iterator rend() BOOST_NOEXCEPT { + return reverse_iterator(begin()); + } + + const_reverse_iterator rend() const BOOST_NOEXCEPT { + return const_reverse_iterator(begin()); + } + + const_iterator cbegin() const BOOST_NOEXCEPT { + return begin(); + } + + const_iterator cend() const BOOST_NOEXCEPT { + return end(); + } + + const_reverse_iterator crbegin() const BOOST_NOEXCEPT { + return rbegin(); + } + + const_reverse_iterator crend() const BOOST_NOEXCEPT { + return rend(); + } + + size_type size() const BOOST_NOEXCEPT { + return _hashes.size(); + } + + size_type complete_size() const BOOST_NOEXCEPT { + return _size; + } + + size_type capacity() const BOOST_NOEXCEPT { + return _hashes.capacity(); + } + + bool empty() const BOOST_NOEXCEPT { + return (_hashes.size() == 0); + } + + size_type max_size() const BOOST_NOEXCEPT { + return _hashes.max_size(); + } + + void reserve(size_type _n) { + return _hashes.reserve(_n); + } + + void shrink_to_fit() BOOST_NOEXCEPT { + return _hashes.shrink_to_fit(); + } + + reference operator[](size_type _n) BOOST_NOEXCEPT { + return _hashes[_n]; + } + + const_reference operator[](size_type _n) const BOOST_NOEXCEPT { + return _hashes[_n]; + } + + reference at(size_type _n) { + return _hashes.at(_n); + } + + const_reference at(size_type _n) const { + return _hashes.at(_n); + } + + reference front() BOOST_NOEXCEPT { + return _hashes.front(); + } + + const_reference front() const BOOST_NOEXCEPT { + return _hashes.front(); + } + + reference back() BOOST_NOEXCEPT { + return _hashes.back(); + } + + const_reference back() const BOOST_NOEXCEPT { + return _hashes.back(); + } + + value_type *hashes() BOOST_NOEXCEPT { + return _hashes; + } + + const value_type *hashes() const BOOST_NOEXCEPT { + return _hashes; + } + + void push_back(const_reference _x) { + // #error ERROR + _hashes.push_back(_x); + } + + void push_back(value_type &&_x) { + // #error ERROR + _hashes.push_back(_x); + } + + // + template + reference emplace_back(Args &&..._args) { + return _hashes.template emplace_back(_args...); + } + + template + iterator emplace(const_iterator _position, Args &&... _args) { + return _hashes.template emplace(_position, _args...); + } + + void pop_back() { + _hashes.pop_back(); + } + + void clear() BOOST_NOEXCEPT { + _hashes.clear(); + } + + void resize(size_type _sz) { + return _hashes.resize(_sz); + } + + void resize(size_type _sz, const_reference _x) { + return _hashes.resize(_sz, _x); + } + + void swap(merkle_tree_impl &other) { + _hashes.swap(other.hashes()); + std::swap(_leaves, other.leaves()); + std::swap(_rc, other.rc()); + std::swap(_size, other.size()); + } + + value_type root() const BOOST_NOEXCEPT { + BOOST_ASSERT_MSG(_size == _hashes.size(), "MerkleTree not fulfilled"); + return _hashes[_size - 1]; + } + + value_type root() BOOST_NOEXCEPT { + BOOST_ASSERT_MSG(_size == _hashes.size(), "MerkleTree not fulfilled"); + return _hashes[_size - 1]; + } + + size_t row_count() const { + return _rc; + } + + size_t leaves() const { + return _leaves; + } + + void set_leaves(size_t s) { + _leaves = s; + } + + void set_row_count(size_t s) { + _rc = s; + } + + void set_complete_size(size_t s) { + _size = s; + } + + protected: + container_type _hashes; + + size_t _size; + size_t _leaves; + // Note: The former 'upstream' merkle_light project uses 'height' + // (with regards to the tree property) incorrectly, so we've + // renamed it since it's actually a '_rc'. For example, a + // tree with 2 leaf nodes and a single root node has a height of + // 1, but a _rc of 2. + // + // Internally, this code considers only the _rc. + size_t _rc; + }; + + template + typename T::digest_type generate_hash(LeafIterator first, LeafIterator last) { + accumulator_set acc; + while (first != last) { + crypto3::hash(*first++, acc); + } + return accumulators::extract::hash(acc); + } + + template::value, bool> = true> + typename T::digest_type generate_poseidon_hash(typename T::digest_type first, typename T::digest_type second) { + using field_type = nil::crypto3::algebra::curves::pallas::base_field_type; + using poseidon_policy = nil::crypto3::hashes::detail::mina_poseidon_policy; + hashes::detail::poseidon_sponge_construction sponge; + sponge.absorb(first); + sponge.absorb(second); + return sponge.squeeze(); + } + + template, + std::enable_if_t::value, bool> = true> + typename T::digest_type generate_poseidon_leaf_hash(const LeafData &leaf) { + using field_type = nil::crypto3::algebra::curves::pallas::base_field_type; + using poseidon_policy = nil::crypto3::hashes::detail::mina_poseidon_policy; + hashes::detail::poseidon_sponge_construction sponge; + std::size_t cur = 1; + for(std::size_t i = 0; i < leaf.size(); i+=64) { + nil::crypto3::multiprecision::cpp_int first = 0; + std::size_t j = 0; + for(; j < 32; j++){ + first <<= 8; + first += leaf[i + j]; + } + nil::crypto3::multiprecision::cpp_int second = 0; + for(; j < 64; j++){ + second <<= 8; + second += leaf[i + j]; + } + sponge.absorb(first); + sponge.absorb(second); + } + if (cur == 2) { + BOOST_ASSERT("Data size should be multiple of 32 bytes"); + } + return sponge.squeeze(); + } + + template::value, bool> = true + > + merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { + BOOST_ASSERT_MSG(Arity == 2, "Only arity 2 is supported for poseidon hash function"); + typedef T node_type; + typedef typename node_type::hash_type hash_type; + + merkle_tree_impl ret(std::distance(first, last)); + + ret.reserve(ret.complete_size()); + + while (first != last) { + ret.emplace_back(generate_poseidon_leaf_hash(*first++)); + } + + std::size_t row_idx = ret.leaves(), row_size = row_idx / Arity; + typename merkle_tree_impl::iterator it = ret.begin(); + + for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { + for (size_t i = 0; i < row_size; ++i, it += Arity) { + ret.emplace_back(generate_poseidon_hash(*it, *(it + 1))); + } + } + return ret; + } + + template::value, bool> = true> + merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { + typedef T node_type; + typedef typename node_type::hash_type hash_type; + + merkle_tree_impl ret(std::distance(first, last)); + ret.reserve(ret.complete_size()); + + while (first != last) { + ret.emplace_back(crypto3::hash(*first++)); + } + + std::size_t row_idx = ret.leaves(), row_size = row_idx / Arity; + typename merkle_tree_impl::iterator it = ret.begin(); + + for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { + for (size_t i = 0; i < row_size; ++i, it += Arity) { + ret.emplace_back(generate_hash(it, it + Arity)); + } + } + return ret; + } + } // namespace detail + + template + using merkle_tree = typename std::conditional::value, + detail::merkle_tree_impl, Arity>, + detail::merkle_tree_impl>::type; + + template + merkle_tree make_merkle_tree(LeafIterator first, LeafIterator last) { + return detail::make_merkle_tree::value, + detail::merkle_tree_node, + T>::type, + Arity>(first, last); + } + + } // namespace containers + } // namespace crypto3 +} // namespace nil + +#endif // CRYPTO3_MERKLE_TREE_HPP diff --git a/include/nil/crypto3/container/sparse_vector.hpp b/include/nil/crypto3/container/sparse_vector.hpp new file mode 100644 index 0000000000..c074e3b263 --- /dev/null +++ b/include/nil/crypto3/container/sparse_vector.hpp @@ -0,0 +1,298 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2021 Mikhail Komarov +// Copyright (c) 2020-2021 Nikita Kaskov +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// +// @file Declaration of interfaces for a sparse vector. +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_ZK_SPARSE_VECTOR_HPP +#define CRYPTO3_ZK_SPARSE_VECTOR_HPP + +#include +#include +#include + +#include +#include + +namespace nil { + namespace crypto3 { + namespace container { + + /** + * A sparse vector is a list of indices along with corresponding values. + * The indices are selected from the set {0,1,...,domain_size-1}. + */ + template + class sparse_vector { + using underlying_value_type = typename Type::value_type; + + template + using container_type = std::vector; + + typedef container_type value_container_type; + + public: + using group_type = Type; + + typedef typename value_container_type::value_type value_type; + typedef typename value_container_type::allocator_type allocator_type; + typedef typename value_container_type::reference reference; + typedef typename value_container_type::const_reference const_reference; + typedef typename value_container_type::size_type size_type; + typedef typename value_container_type::difference_type difference_type; + typedef typename value_container_type::pointer pointer; + typedef typename value_container_type::const_pointer const_pointer; + typedef typename value_container_type::iterator iterator; + typedef typename value_container_type::const_iterator const_iterator; + typedef typename value_container_type::reverse_iterator reverse_iterator; + typedef typename value_container_type::const_reverse_iterator const_reverse_iterator; + + container_type indices; + container_type values; + std::size_t domain_size_; + + sparse_vector() = default; + + sparse_vector(const sparse_vector &other) = default; + + sparse_vector(sparse_vector &&other) = default; + + sparse_vector(value_container_type &&v) : values(std::move(v)), domain_size_(values.size()) { + indices.resize(domain_size_); + std::iota(indices.begin(), indices.end(), 0); + } + + explicit sparse_vector(size_type n) : values(n) { + } + explicit sparse_vector(size_type n, const allocator_type &a) : values(n, a) { + } + + sparse_vector(size_type n, const value_type &x) : values(n, x) { + } + sparse_vector(size_type n, const value_type &x, const allocator_type &a) : values(n, x, a) { + } + template + sparse_vector(InputIterator first, InputIterator last) : values(first, last) { + } + template + sparse_vector(InputIterator first, InputIterator last, const allocator_type &a) : + values(first, last, a) { + } + + ~sparse_vector() = default; + + sparse_vector(std::initializer_list il) : values(il) { + } + + sparse_vector(std::initializer_list il, const allocator_type &a) : values(il, a) { + } + + sparse_vector &operator=(const sparse_vector &other) = default; + sparse_vector &operator=(sparse_vector &&other) = default; + + underlying_value_type operator[](const std::size_t idx) const { + auto it = std::lower_bound(indices.begin(), indices.end(), idx); + return (it != indices.end() && *it == idx) ? values[it - indices.begin()] : underlying_value_type(); + } + + bool operator==(const sparse_vector &other) const { + if (this->domain_size_ != other.domain_size_) { + return false; + } + + std::size_t this_pos = 0, other_pos = 0; + while (this_pos < this->indices.size() && other_pos < other.indices.size()) { + if (this->indices[this_pos] == other.indices[other_pos]) { + if (this->values[this_pos] != other.values[other_pos]) { + return false; + } + ++this_pos; + ++other_pos; + } else if (this->indices[this_pos] < other.indices[other_pos]) { + if (!this->values[this_pos].is_zero()) { + return false; + } + ++this_pos; + } else { + if (!other.values[other_pos].is_zero()) { + return false; + } + ++other_pos; + } + } + + /* at least one of the vectors has been exhausted, so other must be empty */ + while (this_pos < this->indices.size()) { + if (!this->values[this_pos].is_zero()) { + return false; + } + ++this_pos; + } + + while (other_pos < other.indices.size()) { + if (!other.values[other_pos].is_zero()) { + return false; + } + ++other_pos; + } + + return true; + } + + bool operator==(const value_container_type &other) const { + if (this->domain_size_ < other.size()) { + return false; + } + + std::size_t j = 0; + for (std::size_t i = 0; i < other.size(); ++i) { + if (this->indices[j] == i) { + if (this->values[j] != other[j]) { + return false; + } + ++j; + } else { + if (!other[j].is_zero()) { + return false; + } + } + } + + return true; + } + + bool is_valid() const { + if (values.size() == indices.size() && values.size() <= domain_size_) { + return false; + } + + for (std::size_t i = 0; i + 1 < indices.size(); ++i) { + if (indices[i] >= indices[i + 1]) { + return false; + } + } + + if (!indices.empty() && indices[indices.size() - 1] >= domain_size_) { + return false; + } + + return true; + } + + bool empty() const { + return indices.empty(); + } + + std::size_t domain_size() const { + return domain_size_; + } + + std::size_t size() const { + return indices.size(); + } + + std::size_t size_in_bits() const { + return indices.size() * (sizeof(std::size_t) * 8 + Type::value_bits); + } + + /* return a pair consisting of the accumulated value and the sparse vector of non-accumulated values + */ + template + std::pair> + insert(std::size_t offset, InputBaseIterator first, InputBaseIterator last) const { +#ifdef MULTICORE + const std::size_t chunks = omp_get_max_threads(); // to override, set OMP_NUM_THREADS env var + // or call omp_set_num_threads() +#else + const std::size_t chunks = 1; +#endif + + underlying_value_type accumulated_value = underlying_value_type::zero(); + sparse_vector resulting_vector; + resulting_vector.domain_size_ = domain_size_; + + const std::size_t range_len = std::distance(first, last); + bool in_block = false; + std::size_t first_pos = -1, + last_pos = -1; // g++ -flto emits unitialized warning, even though in_block + // guards for such cases. + + for (std::size_t i = 0; i < indices.size(); ++i) { + const bool matching_pos = (offset <= indices[i] && indices[i] < offset + range_len); + // printf("i = %zu, pos[i] = %zu, offset = %zu, w_size = %zu\n", i, indices[i], offset, + // w_size); + bool copy_over; + + if (in_block) { + if (matching_pos && last_pos == i - 1) { + // block can be extended, do it + last_pos = i; + copy_over = false; + } else { + // block has ended here + in_block = false; + copy_over = true; + + accumulated_value = accumulated_value + + algebra::multiexp( + values.begin() + first_pos, values.begin() + last_pos + 1, + first + (indices[first_pos] - offset), + last + (indices[last_pos] - offset) + 1, chunks); + } + } else { + if (matching_pos) { + // block can be started + first_pos = i; + last_pos = i; + in_block = true; + copy_over = false; + } else { + copy_over = true; + } + } + + if (copy_over) { + resulting_vector.indices.emplace_back(indices[i]); + resulting_vector.values.emplace_back(values[i]); + } + } + + if (in_block) { + accumulated_value = + accumulated_value + algebra::multiexp( + values.begin() + first_pos, + values.begin() + last_pos + 1, + first + (indices[first_pos] - offset), + first + (indices[last_pos] - offset) + 1, + chunks); + } + + return std::make_pair(accumulated_value, resulting_vector); + } + }; + } // namespace container + } // namespace crypto3 +} // namespace nil + +#endif // CRYPTO3_ZK_SPARSE_VECTOR_HPP diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 95de704bcd..ad1873ee28 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,7 +2,7 @@ # MIT License # # Copyright (c) 2020 Mikhail Komarov -# Copyright (c) 2021-2022 Aleksei Moskvin +# Copyright (c) 2021 Aleksei Moskvin # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -25,105 +25,59 @@ include(CMTest) -if (NOT Boost_UNIT_TEST_FRAMEWORK_FOUND) +if(NOT Boost_UNIT_TEST_FRAMEWORK_FOUND) cm_find_package(Boost REQUIRED COMPONENTS unit_test_framework) -endif () - -function(actor_add_test name) - get_filename_component(test_name ${name} NAME) - string(REPLACE "/" "_" target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${test_name}_test) - - set(test_kinds - ACTOR - BOOST - CUSTOM) - - cmake_parse_arguments(parsed_args - "" - "WORKING_DIRECTORY;KIND" - "RUN_ARGS;SOURCES;LIBRARIES;DEPENDS" - ${ARGN}) - - if(NOT parsed_args_KIND) - set(parsed_args_KIND ACTOR) - elseif(NOT (parsed_args_KIND IN_LIST test_kinds)) - message(FATAL_ERROR "Invalid test kind. KIND must be one of ${test_kinds}") - endif() - - if(parsed_args_SOURCES) - # - # Each kind of test must populate the `args` and `libraries` lists. - # - - set(libraries "${parsed_args_LIBRARIES}") - list(APPEND libraries - ${CMAKE_WORKSPACE_NAME}::core - ${CMAKE_WORKSPACE_NAME}::network - ${CMAKE_WORKSPACE_NAME}::testing -# epoll-shim - - crypto3::algebra - crypto3::hash - crypto3::containers) +endif() +cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} - set(args "") - if(parsed_args_KIND STREQUAL "ACTOR") - list(APPEND args -- -c ${BUILD_WITH_UNIT_TEST_SMP}) - endif() + ${CMAKE_WORKSPACE_NAME}::algebra + ${CMAKE_WORKSPACE_NAME}::hash - if(NOT (UNIX AND (CMAKE_SYSTEM_NAME STREQUAL "Linux"))) - list(APPEND libraries epoll-shim) - endif() + ${Boost_LIBRARIES}) - list(APPEND args ${parsed_args_RUN_ARGS}) +macro(define_storage_test test) + get_filename_component(test_name ${test} NAME) + set(target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${test_name}_test) - cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} - ${libraries} - ${Boost_LIBRARIES}) + while(TARGET ${target_name}) + get_filename_component(TEST_DIRECTORY ${test} DIRECTORY) + get_filename_component(PARENT_DIR ${TEST_DIRECTORY} DIRECTORY) + set(target_name ${PARENT_DIR}_${target_name}) + endwhile() - cm_test(NAME ${target_name} SOURCES ${parsed_args_SOURCES}) + set(additional_args "") + if(ENABLE_JUNIT_TEST_OUTPUT) + set(TEST_RESULTS_DIR "${CMAKE_CURRENT_BINARY_DIR}/junit_results") + set(TEST_LOGS_DIR "${TEST_RESULTS_DIR}/logs") + file(MAKE_DIRECTORY ${TEST_LOGS_DIR}) - target_compile_definitions(${target_name} PRIVATE - ACTOR_TESTING_MAIN BOOST_TEST_DYN_LINK) + set(additional_args "--log_format=JUNIT" + "--log_sink=${TEST_LOGS_DIR}/${target_name}.xml") + endif() - if((BUILD_WITH_STACK_GUARDS STREQUAL "ON") OR - ((BUILD_WITH_STACK_GUARDS STREQUAL "DEFAULT") AND - (CMAKE_BUILD_TYPE IN_LIST ACTOR_STACK_GUARD_MODES))) - target_compile_definitions(${target_name} - PRIVATE ACTOR_THREAD_STACK_GUARDS) - endif() + cm_test(NAME ${target_name} SOURCES ${test}.cpp ARGS ${additional_args}) - target_include_directories(${target_name} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${BUILD_WITH_SOURCE_DIR}/src) + target_include_directories(${target_name} PRIVATE + "$" + "$" - set_target_properties(${target_name} PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED TRUE) + ${Boost_INCLUDE_DIRS}) - target_compile_options(${target_name} PRIVATE - ${${CURRENT_PROJECT_NAME}_PRIVATE_CXX_FLAGS}) + set_target_properties(${target_name} PROPERTIES CXX_STANDARD 17) - get_target_property(target_type Boost::unit_test_framework TYPE) - if (target_type STREQUAL "SHARED_LIB") - target_compile_definitions(${target_name} PRIVATE BOOST_TEST_DYN_LINK) - elseif (target_type STREQUAL "STATIC_LIB") + get_target_property(target_type Boost::unit_test_framework TYPE) + if(target_type STREQUAL "SHARED_LIB") + target_compile_definitions(${target_name} PRIVATE BOOST_TEST_DYN_LINK) + elseif(target_type STREQUAL "STATIC_LIB") - endif () - else() - if(NOT (parsed_args_KIND STREQUAL "CUSTOM")) - message(FATAL_ERROR "SOURCES are required for ${parsed_args_KIND} tests") - endif() endif() - - -endfunction() +endmacro() set(TESTS_NAMES - "merkle/merkle" - ) + "merkle/merkle" +) -foreach (TEST_NAME ${TESTS_NAMES}) - actor_add_test(${TEST_NAME} SOURCES ${TEST_NAME}.cpp) -endforeach () \ No newline at end of file +foreach(TEST_NAME ${TESTS_NAMES}) + define_storage_test(${TEST_NAME}) +endforeach() diff --git a/test/merkle/merkle.cpp b/test/merkle/merkle.cpp index e6c1beaeaa..67ac0d12dd 100644 --- a/test/merkle/merkle.cpp +++ b/test/merkle/merkle.cpp @@ -1,48 +1,52 @@ -////---------------------------------------------------------------------------// -//// Copyright (c) 2018-2020 Mikhail Komarov -//// Copyright (c) 2021-2022 Aleksei Moskvin -//// -//// MIT License -//// -//// Permission is hereby granted, free of charge, to any person obtaining a copy -//// of this software and associated documentation files (the "Software"), to deal -//// in the Software without restriction, including without limitation the rights -//// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -//// copies of the Software, and to permit persons to whom the Software is -//// furnished to do so, subject to the following conditions: -//// -//// The above copyright notice and this permission notice shall be included in all -//// copies or substantial portions of the Software. -//// -//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -//// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -//// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -//// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -//// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -//// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -//// SOFTWARE. -////---------------------------------------------------------------------------// +//---------------------------------------------------------------------------// +// Copyright (c) 2018-2020 Mikhail Komarov +// Copyright (c) 2021-2022 Aleksei Moskvin +// Copyright (c) 2021 Ilias Khairullin +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#define BOOST_TEST_MODULE containter_merkletree_test #include #include #include #include - -#include -#include -#include +#include #include #include -#include -#include +#include +#include +#include -#include #include +#include +#include +#include +#include -#include -#include +using namespace nil::crypto3; +using namespace nil::crypto3::containers; template typename std::enable_if::value, std::vector>>::type @@ -61,10 +65,10 @@ template void testing_validate_template_random_data(std::size_t leaf_number) { std::array data_not_in_tree = {0}; auto data = generate_random_data(leaf_number); - auto tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()).get(); + auto tree = make_merkle_tree(data.begin(), data.end()); std::size_t proof_idx = std::rand() % leaf_number; - nil::crypto3::containers::merkle_proof proof(tree, proof_idx); + merkle_proof proof(tree, proof_idx); bool good_validate = proof.validate(data[proof_idx]); bool wrong_leaf_validate = proof.validate(data[(proof_idx + 1) % leaf_number]); bool wrong_data_validate = proof.validate(data_not_in_tree); @@ -76,8 +80,13 @@ void testing_validate_template_random_data(std::size_t leaf_number) { template void testing_validate_template(std::vector data) { std::array data_not_in_tree = {'\x6d', '\x65', '\x73', '\x73', '\x61', '\x67', '\x65'}; - nil::crypto3::containers::merkle_tree tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()).get(); - nil::crypto3::containers::merkle_proof proof(tree, 0); + merkle_tree tree = make_merkle_tree(data.begin(), data.end()); + merkle_tree tree2(tree.begin(), tree.end()); +// for (auto i = 0; i < tree.size(); ++i) { +// std::cout << tree[i] << std::endl; +// } +// tree.emplace_back(nil::crypto3::hash(data_not_in_tree[0])); + merkle_proof proof(tree, 0); bool good_validate = proof.validate(data[0]); bool wrong_leaf_validate = proof.validate(data[1]); bool wrong_data_validate = proof.validate(data_not_in_tree); @@ -86,43 +95,241 @@ void testing_validate_template(std::vector data) { BOOST_CHECK(false == wrong_data_validate); } +template +void testing_validate_template_random_data_compressed_proofs(std::size_t leaf_number) { + using merkle_proof_type = typename containers::merkle_proof; + using Element = std::array; + std::array data_not_in_tree = {0}; + auto data = generate_random_data(leaf_number); + auto tree = make_merkle_tree(data.begin(), data.end()); + + std::size_t num_idxs = std::rand() % leaf_number; + while (num_idxs == 0) { + num_idxs = std::rand() % leaf_number; + } + + std::vector proof_idxs; + std::vector data_for_validation; + for (std::size_t i = 0; i < num_idxs; ++i) { + proof_idxs.emplace_back(std::rand() % leaf_number); + } + for (auto idx : proof_idxs) { + data_for_validation.emplace_back(data[idx]); + } + + // standard case + auto start = std::chrono::high_resolution_clock::now(); + std::vector> compressed_proofs = merkle_proof_type::generate_compressed_proofs(tree, proof_idxs); + bool validate_compressed = merkle_proof_type::validate_compressed_proofs(compressed_proofs, data_for_validation); + auto duration = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - start); + // case for arity == 4 + if (leaf_number == 16) { + std::vector> compressed_proofs_one_idx = merkle_proof_type::generate_compressed_proofs(tree, {3, 2, 1, 5, 11, 11, 0}); + bool validate_compressed_one_idx = merkle_proof_type::validate_compressed_proofs(compressed_proofs_one_idx, std::vector({data[3], data[2], data[1], data[5], data[11], data[11], data[0]})); + BOOST_CHECK(validate_compressed_one_idx); + } + // one index + std::size_t one_idx = std::rand() % leaf_number; + std::vector> compressed_proofs_one_idx = merkle_proof_type::generate_compressed_proofs(tree, {one_idx}); + bool validate_compressed_one_idx = merkle_proof_type::validate_compressed_proofs(compressed_proofs_one_idx, std::vector({data[one_idx]})); + // edge indexes + std::vector> compressed_proofs_edge_idxs = merkle_proof_type::generate_compressed_proofs(tree, {0, leaf_number - 1}); + bool validate_compressed_edge_idxs = merkle_proof_type::validate_compressed_proofs(compressed_proofs_edge_idxs, std::vector({data[0], data[leaf_number - 1]})); + // repeated indexes + std::size_t repeated_idx = std::rand() % leaf_number; + std::vector> compressed_proofs_repeated_idxs = merkle_proof_type::generate_compressed_proofs(tree, {repeated_idx, leaf_number / 2, repeated_idx}); + bool validate_compressed_repeated_idxs = merkle_proof_type::validate_compressed_proofs(compressed_proofs_repeated_idxs, std::vector({data[repeated_idx], data[leaf_number / 2], data[repeated_idx]})); + // wrong leaf + auto sorted_idxs = proof_idxs; + std::sort(sorted_idxs.begin(), sorted_idxs.end()); + std::size_t wrong_leaf_idx = 0; + for (auto idx : sorted_idxs) { + if (idx == wrong_leaf_idx) { + wrong_leaf_idx++; + } else { + break; + } + } + auto data_wrong_leaf = data_for_validation; + data_wrong_leaf[std::rand() % num_idxs] = data[wrong_leaf_idx]; + assert(data_wrong_leaf != data_for_validation); + bool wrong_leaf_validate_compressed = merkle_proof_type::validate_compressed_proofs(compressed_proofs, data_wrong_leaf); + // wrong data + auto data_wrong_data = data_for_validation; + data_wrong_data[std::rand() % num_idxs] = data_not_in_tree; + assert(data_wrong_data != data_for_validation); + bool wrong_data_validate_compressed = merkle_proof_type::validate_compressed_proofs(compressed_proofs, data_wrong_data); + + BOOST_CHECK(validate_compressed); + BOOST_CHECK(validate_compressed_one_idx); + BOOST_CHECK(validate_compressed_edge_idxs); + BOOST_CHECK(validate_compressed_repeated_idxs); + BOOST_CHECK(!wrong_leaf_validate_compressed); + BOOST_CHECK(!wrong_data_validate_compressed); +} + +template +void testing_validate_template_compressed_proofs(std::vector data) { + using merkle_proof_type = typename containers::merkle_proof; + merkle_tree tree = make_merkle_tree(data.begin(), data.end()); + + std::size_t leaf_number = data.size(); + std::size_t num_idxs = std::rand() % leaf_number; + while (num_idxs == 0) { + num_idxs = std::rand() % leaf_number; + } + std::vector proof_idxs; + std::vector data_for_validation; + for (std::size_t i = 0; i < num_idxs; ++i) { + proof_idxs.emplace_back(std::rand() % leaf_number); + } + for (auto idx : proof_idxs) { + data_for_validation.emplace_back(data[idx]); + } + + // standart case + std::vector> compressed_proofs = merkle_proof_type::generate_compressed_proofs(tree, proof_idxs); + bool validate_compressed = merkle_proof_type::validate_compressed_proofs(compressed_proofs, data_for_validation); + // one index + std::size_t one_idx = std::rand() % leaf_number; + std::vector> compressed_proofs_one_idx = merkle_proof_type::generate_compressed_proofs(tree, {one_idx}); + bool validate_compressed_one_idx = merkle_proof_type::validate_compressed_proofs(compressed_proofs_one_idx, std::vector({data[one_idx]})); + // edge indexes + std::vector> compressed_proofs_edge_idxs = merkle_proof_type::generate_compressed_proofs(tree, {0, leaf_number - 1}); + bool validate_compressed_edge_idxs = merkle_proof_type::validate_compressed_proofs(compressed_proofs_edge_idxs, std::vector({data[0], data[leaf_number - 1]})); + // repeated indexes + std::size_t repeated_idx = std::rand() % leaf_number; + std::vector> compressed_proofs_repeated_idxs = merkle_proof_type::generate_compressed_proofs(tree, {repeated_idx, leaf_number - 1, repeated_idx}); + bool validate_compressed_repeated_idxs = merkle_proof_type::validate_compressed_proofs(compressed_proofs_repeated_idxs, std::vector({data[repeated_idx], data[leaf_number - 1], data[repeated_idx]})); + // wrong leaf + auto sorted_idxs = proof_idxs; + std::sort(sorted_idxs.begin(), sorted_idxs.end()); + std::size_t wrong_leaf_idx = 0; + for (auto idx : sorted_idxs) { + if (idx == wrong_leaf_idx) { + wrong_leaf_idx++; + } else { + break; + } + } + auto data_wrong_leaf = data_for_validation; + data_wrong_leaf[std::rand() % num_idxs] = data[wrong_leaf_idx]; + assert(data_wrong_leaf != data_for_validation); + bool wrong_leaf_validate_compressed = merkle_proof_type::validate_compressed_proofs(compressed_proofs, data_wrong_leaf); + // wrong data + auto data_wrong_data = data_for_validation; + data_wrong_data[std::rand() % num_idxs] = {'9'}; + assert(data_wrong_data != data_for_validation); + bool wrong_data_validate_compressed = merkle_proof_type::validate_compressed_proofs(compressed_proofs, data_wrong_data); + + BOOST_CHECK(validate_compressed); + BOOST_CHECK(validate_compressed_one_idx); + BOOST_CHECK(validate_compressed_edge_idxs); + BOOST_CHECK(validate_compressed_repeated_idxs); + BOOST_CHECK(!wrong_leaf_validate_compressed); + BOOST_CHECK(!wrong_data_validate_compressed); +} + template void testing_hash_template(std::vector data, std::string result) { - nil::crypto3::containers::merkle_tree tree = nil::actor::containers::make_merkle_tree(data.begin(), data.end()).get(); + merkle_tree tree = make_merkle_tree(data.begin(), data.end()); BOOST_CHECK(result == std::to_string(tree.root())); } -using namespace nil::actor; +BOOST_AUTO_TEST_SUITE(containers_merkltree_test) -ACTOR_THREAD_TEST_CASE(merkletree_validate_test_1) { +using curve_type = algebra::curves::pallas; +using field_type = typename curve_type::base_field_type; +using poseidon_type = hashes::poseidon>; + +BOOST_AUTO_TEST_CASE(merkletree_construct_test_1) { std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}}; - testing_validate_template, 2>(v); - testing_validate_template(v); - testing_validate_template, 2>(v); - - std::size_t leaf_number = 64; - testing_validate_template_random_data, 2, std::uint8_t, 1>(leaf_number); - testing_validate_template_random_data(leaf_number); - testing_validate_template_random_data, 2, std::uint8_t, 1>(leaf_number); + merkle_tree, 2> tree_res = make_merkle_tree, 2>(v.begin(), v.end()); + merkle_tree, 2> tree(tree_res.begin(), tree_res.end()); + BOOST_CHECK_EQUAL(tree.size(), 15); + BOOST_CHECK_EQUAL(tree.leaves(), 8); + BOOST_CHECK_EQUAL(tree.row_count(), 4); } -ACTOR_THREAD_TEST_CASE(merkletree_validate_test_2) { +BOOST_AUTO_TEST_CASE(merkletree_construct_test_2) { std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; - testing_validate_template, 3>(v); - testing_validate_template(v); - testing_validate_template, 3>(v); - - std::size_t leaf_number = 81; - testing_validate_template_random_data, 3, std::uint8_t, 1>(leaf_number); - testing_validate_template_random_data(leaf_number); - testing_validate_template_random_data, 3, std::uint8_t, 1>(leaf_number); + merkle_tree, 3> tree_res = make_merkle_tree, 3>(v.begin(), v.end()); + merkle_tree, 3> tree(tree_res.begin(), tree_res.end()); + BOOST_CHECK_EQUAL(tree.size(), 13); + BOOST_CHECK_EQUAL(tree.leaves(), 9); + BOOST_CHECK_EQUAL(tree.row_count(), 3); } -ACTOR_THREAD_TEST_CASE(merkletree_validate_test_3) { - using hash_type = nil::crypto3::hashes::pedersen< - nil::crypto3::hashes::find_group_hash_default_params, nil::crypto3::hashes::sha2<256>, - nil::crypto3::algebra::curves::jubjub::template g1_type> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}}; + testing_validate_template, 2>(v); + testing_validate_template(v); + testing_validate_template, 2>(v); + testing_validate_template(v); + + std::size_t leaf_number = 8; + testing_validate_template_random_data, 2, std::uint8_t, 1>(leaf_number); + testing_validate_template_random_data(leaf_number); + testing_validate_template_random_data, 2, std::uint8_t, 1>(leaf_number); + testing_validate_template_random_data(leaf_number); +} + +BOOST_AUTO_TEST_CASE(merkletree_validate_test_2) { + std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; + testing_validate_template, 3>(v); + testing_validate_template(v); + testing_validate_template, 3>(v); + + std::size_t leaf_number = 9; + testing_validate_template_random_data, 3, std::uint8_t, 1>(leaf_number); + testing_validate_template_random_data(leaf_number); + testing_validate_template_random_data, 3, std::uint8_t, 1>(leaf_number); +} + +BOOST_AUTO_TEST_CASE(merkletree_validate_test_3) { + using hash_type = hashes::pedersen< + hashes::find_group_hash_default_params, hashes::sha2<256>, + algebra::curves::jubjub::template g1_type>; std::size_t leaf_number = 8; testing_validate_template_random_data(leaf_number); -} \ No newline at end of file +} + +BOOST_AUTO_TEST_CASE(merkletree_validate_test_4) { + using hash_type = hashes::pedersen< + hashes::find_group_hash_default_params, hashes::sha2<256>, + algebra::curves::jubjub::template g1_type>; + testing_validate_template_random_data_compressed_proofs(8); + testing_validate_template_random_data_compressed_proofs(9); + testing_validate_template_random_data_compressed_proofs(16); +} + +BOOST_AUTO_TEST_CASE(merkletree_validate_test_5) { + std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; + testing_validate_template_compressed_proofs, 3>(v); + testing_validate_template_compressed_proofs(v); + testing_validate_template_compressed_proofs, 3>(v); + + std::size_t leaf_number = 16; + testing_validate_template_random_data_compressed_proofs, 4, std::uint8_t, 1>(leaf_number); + testing_validate_template_random_data_compressed_proofs(leaf_number); + testing_validate_template_random_data_compressed_proofs, 4, std::uint8_t, 1>(leaf_number); +} + +BOOST_AUTO_TEST_CASE(merkletree_hash_test_1) { + std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}}; + testing_hash_template, 2>(v, "3b828c4f4b48c5d4cb5562a474ec9e2fd8d5546fae40e90732ef635892e42720"); + testing_hash_template(v, "11ee8b50825ce6f816a1ae06d4aa0045"); + testing_hash_template, 2>(v, "0ed2a2145cae554ca57f08420d6cb58629ca1e89dc92f819c6c1d13d"); +} + +BOOST_AUTO_TEST_CASE(merkletree_hash_test_2) { + std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}, {'8'}}; + testing_hash_template, 3>(v, "6831d4d32538bedaa7a51970ac10474d5884701c840781f0a434e5b6868d4b73"); + testing_hash_template(v, "0733c4cd580b1523cfbb9751f42e9420"); + testing_hash_template, 3>(v, "d9d0ff26d10aaac2882c08eb2b55e78690c949d1a73b1cfc0eb322ee"); +} + +BOOST_AUTO_TEST_SUITE_END() From c52b1d8b5ff5ea26fa343be59e4992b996ccbbcd Mon Sep 17 00:00:00 2001 From: Martun Karapetyan Date: Wed, 14 Feb 2024 12:30:54 +0400 Subject: [PATCH 13/23] New actor containers. --- CMakeLists.txt | 8 ++-- .../nil/crypto3/container/merkle/proof.hpp | 7 +-- include/nil/crypto3/container/merkle/tree.hpp | 47 +++++++++++++------ test/CMakeLists.txt | 4 +- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 753eff0125..9b0b7396fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake" include(CMConfig) include(CMSetupVersion) -cm_workspace(crypto3) +cm_workspace(actor) macro(cm_find_package NAME) if (NOT "${NAME}" MATCHES "^${CMAKE_WORKSPACE_NAME}_.*$" AND NOT "${NAME}" STREQUAL CM) @@ -82,8 +82,10 @@ set_target_properties(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} PROPERTIES target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE - ${CMAKE_WORKSPACE_NAME}::algebra - ${CMAKE_WORKSPACE_NAME}::hash + ${CMAKE_WORKSPACE_NAME}::core + + crypto3::algebra + crypto3::hash ${Boost_LIBRARIES}) diff --git a/include/nil/crypto3/container/merkle/proof.hpp b/include/nil/crypto3/container/merkle/proof.hpp index 6cae846bec..2fd886d575 100644 --- a/include/nil/crypto3/container/merkle/proof.hpp +++ b/include/nil/crypto3/container/merkle/proof.hpp @@ -42,13 +42,13 @@ namespace nil { namespace zk { namespace components { template - class merkle_proof; + struct merkle_proof; } // namespace components } // namespace zk namespace marshalling { namespace types { template - class merkle_proof_marshalling; + struct merkle_proof_marshalling; } } // namespace marshalling namespace containers { @@ -95,7 +95,7 @@ namespace nil { typedef std::array layer_type; typedef std::vector path_type; - merkle_proof_impl() : _li(0), _root(value_type()) {}; + merkle_proof_impl() : _li(0) {}; merkle_proof_impl(std::size_t li, value_type root, path_type path) : _li(li), _root(root), _path(path){}; @@ -159,6 +159,7 @@ namespace nil { constexpr static const std::size_t arity = Arity; + constexpr static const std::size_t value_bits = node_type::value_bits; typedef typename node_type::value_type value_type; value_type d = generate_poseidon_leaf_hash(a);// crypto3::hash(a); diff --git a/include/nil/crypto3/container/merkle/tree.hpp b/include/nil/crypto3/container/merkle/tree.hpp index 0b86d9c9cd..f0c3389693 100644 --- a/include/nil/crypto3/container/merkle/tree.hpp +++ b/include/nil/crypto3/container/merkle/tree.hpp @@ -42,6 +42,9 @@ #include #include +#include +#include + namespace nil { namespace crypto3 { namespace containers { @@ -498,7 +501,7 @@ namespace nil { using poseidon_policy = nil::crypto3::hashes::detail::mina_poseidon_policy; hashes::detail::poseidon_sponge_construction sponge; std::size_t cur = 1; - for(std::size_t i = 0; i < leaf.size(); i+=64) { + for (std::size_t i = 0; i < leaf.size(); i += 64) { nil::crypto3::multiprecision::cpp_int first = 0; std::size_t j = 0; for(; j < 32; j++){ @@ -527,22 +530,29 @@ namespace nil { BOOST_ASSERT_MSG(Arity == 2, "Only arity 2 is supported for poseidon hash function"); typedef T node_type; typedef typename node_type::hash_type hash_type; + typedef typename node_type::value_type value_type; + typedef typename std::iterator_traits::value_type leaf_value_type; merkle_tree_impl ret(std::distance(first, last)); - ret.reserve(ret.complete_size()); + ret.resize(ret.complete_size()); - while (first != last) { - ret.emplace_back(generate_poseidon_leaf_hash(*first++)); - } + nil::crypto3::parallel_transform(first, last, ret.begin(), [](const leaf_value_type& leaf) { + return static_cast(generate_poseidon_leaf_hash(leaf)); + }); std::size_t row_idx = ret.leaves(), row_size = row_idx / Arity; typename merkle_tree_impl::iterator it = ret.begin(); + std::size_t next_row_start_index = std::distance(first, last); + for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { - for (size_t i = 0; i < row_size; ++i, it += Arity) { - ret.emplace_back(generate_poseidon_hash(*it, *(it + 1))); - } + nil::crypto3::parallel_for(0, row_size, [&ret, it, next_row_start_index](std::size_t index) { + ret[next_row_start_index + index] = generate_poseidon_hash( + *(it + index * Arity), *(it + index * Arity + 1)); + }); + next_row_start_index += row_size; + it += row_size * Arity; } return ret; } @@ -552,21 +562,28 @@ namespace nil { merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { typedef T node_type; typedef typename node_type::hash_type hash_type; + typedef typename node_type::value_type value_type; + typedef typename std::iterator_traits::value_type leaf_value_type; merkle_tree_impl ret(std::distance(first, last)); - ret.reserve(ret.complete_size()); + ret.resize(ret.complete_size()); - while (first != last) { - ret.emplace_back(crypto3::hash(*first++)); - } + nil::crypto3::parallel_transform(first, last, ret.begin(), [](const leaf_value_type& leaf) { + return static_cast(crypto3::hash(leaf)); + }); std::size_t row_idx = ret.leaves(), row_size = row_idx / Arity; typename merkle_tree_impl::iterator it = ret.begin(); + std::size_t next_row_start_index = std::distance(first, last); + for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { - for (size_t i = 0; i < row_size; ++i, it += Arity) { - ret.emplace_back(generate_hash(it, it + Arity)); - } + nil::crypto3::parallel_for(0, row_size, [&ret, it, next_row_start_index](std::size_t index) { + ret[next_row_start_index + index] = generate_hash( + it + index * Arity, it + (index + 1) * Arity); + }); + next_row_start_index += row_size; + it += row_size * Arity; } return ret; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ad1873ee28..25975dacf0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -31,8 +31,8 @@ endif() cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} - ${CMAKE_WORKSPACE_NAME}::algebra - ${CMAKE_WORKSPACE_NAME}::hash + crypto3::algebra + crypto3::hash ${Boost_LIBRARIES}) From 6106726bfccad08a74c55b030bcce9a56d842e9b Mon Sep 17 00:00:00 2001 From: Iluvmagick Date: Mon, 19 Feb 2024 14:22:43 +0400 Subject: [PATCH 14/23] Corrected error handling in generate_poseidon_leaf_hash. --- include/nil/crypto3/container/merkle/tree.hpp | 9 +++------ test/merkle/merkle.cpp | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/nil/crypto3/container/merkle/tree.hpp b/include/nil/crypto3/container/merkle/tree.hpp index f0c3389693..d139849fbf 100644 --- a/include/nil/crypto3/container/merkle/tree.hpp +++ b/include/nil/crypto3/container/merkle/tree.hpp @@ -500,7 +500,7 @@ namespace nil { using field_type = nil::crypto3::algebra::curves::pallas::base_field_type; using poseidon_policy = nil::crypto3::hashes::detail::mina_poseidon_policy; hashes::detail::poseidon_sponge_construction sponge; - std::size_t cur = 1; + BOOST_ASSERT_MSG(leaf.size() % 64 == 0, "Leaf size must be a multiple of 64"); for (std::size_t i = 0; i < leaf.size(); i += 64) { nil::crypto3::multiprecision::cpp_int first = 0; std::size_t j = 0; @@ -516,9 +516,6 @@ namespace nil { sponge.absorb(first); sponge.absorb(second); } - if (cur == 2) { - BOOST_ASSERT("Data size should be multiple of 32 bytes"); - } return sponge.squeeze(); } @@ -549,7 +546,7 @@ namespace nil { for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { nil::crypto3::parallel_for(0, row_size, [&ret, it, next_row_start_index](std::size_t index) { ret[next_row_start_index + index] = generate_poseidon_hash( - *(it + index * Arity), *(it + index * Arity + 1)); + *(it + index * Arity), *(it + index * Arity + 1)); }); next_row_start_index += row_size; it += row_size * Arity; @@ -580,7 +577,7 @@ namespace nil { for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { nil::crypto3::parallel_for(0, row_size, [&ret, it, next_row_start_index](std::size_t index) { ret[next_row_start_index + index] = generate_hash( - it + index * Arity, it + (index + 1) * Arity); + it + index * Arity, it + (index + 1) * Arity); }); next_row_start_index += row_size; it += row_size * Arity; diff --git a/test/merkle/merkle.cpp b/test/merkle/merkle.cpp index 67ac0d12dd..55845bdbe3 100644 --- a/test/merkle/merkle.cpp +++ b/test/merkle/merkle.cpp @@ -116,7 +116,7 @@ void testing_validate_template_random_data_compressed_proofs(std::size_t leaf_nu for (auto idx : proof_idxs) { data_for_validation.emplace_back(data[idx]); } - + // standard case auto start = std::chrono::high_resolution_clock::now(); std::vector> compressed_proofs = merkle_proof_type::generate_compressed_proofs(tree, proof_idxs); @@ -159,7 +159,7 @@ void testing_validate_template_random_data_compressed_proofs(std::size_t leaf_nu data_wrong_data[std::rand() % num_idxs] = data_not_in_tree; assert(data_wrong_data != data_for_validation); bool wrong_data_validate_compressed = merkle_proof_type::validate_compressed_proofs(compressed_proofs, data_wrong_data); - + BOOST_CHECK(validate_compressed); BOOST_CHECK(validate_compressed_one_idx); BOOST_CHECK(validate_compressed_edge_idxs); @@ -241,7 +241,7 @@ BOOST_AUTO_TEST_SUITE(containers_merkltree_test) using curve_type = algebra::curves::pallas; using field_type = typename curve_type::base_field_type; using poseidon_type = hashes::poseidon>; - + BOOST_AUTO_TEST_CASE(merkletree_construct_test_1) { std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}}; merkle_tree, 2> tree_res = make_merkle_tree, 2>(v.begin(), v.end()); From 4a6edc273828c2e5a4523be3e1be3caa65b7bb9a Mon Sep 17 00:00:00 2001 From: x-mass <36629999+x-mass@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:30:02 +0000 Subject: [PATCH 15/23] Add canon data test for poseidon --- test/merkle/merkle.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/merkle/merkle.cpp b/test/merkle/merkle.cpp index 55845bdbe3..3282e9ec7e 100644 --- a/test/merkle/merkle.cpp +++ b/test/merkle/merkle.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -323,6 +324,17 @@ BOOST_AUTO_TEST_CASE(merkletree_hash_test_1) { testing_hash_template, 2>(v, "3b828c4f4b48c5d4cb5562a474ec9e2fd8d5546fae40e90732ef635892e42720"); testing_hash_template(v, "11ee8b50825ce6f816a1ae06d4aa0045"); testing_hash_template, 2>(v, "0ed2a2145cae554ca57f08420d6cb58629ca1e89dc92f819c6c1d13d"); + testing_hash_template, 2>(v, "568ff5eb286f51b8a3e8de4e53aa8daed44594a246deebbde119ea2eb27acd6b"); + testing_hash_template, 2>(v, "1a0ca31dd9e0b27afdf77021dc50023cdd814eb53ede16e8c5c322a0bcb6bd7d26a0404e5af53971e1566c1649bb9686905cdedfa9a358023065e423522d4372"); + + std::vector v_64 = { + "0123456789012345678901234567890123456789012345678901234567890123", + "0123456789012345678901234567890123456789012345678901234567890123", + "0123456789012345678901234567890123456789012345678901234567890123", + "0123456789012345678901234567890123456789012345678901234567890123" + }; + merkle_tree tree = make_merkle_tree(v_64.begin(), v_64.end()); + BOOST_CHECK(tree.root() == 0x6E7641F1EAE17C0DA8227840EFEA6E1D17FB5EBA600D9DC34F314D5400E5BF3_cppui255); } BOOST_AUTO_TEST_CASE(merkletree_hash_test_2) { From 2cb15c9585207b57ef86121c89fdf37539e2f8fd Mon Sep 17 00:00:00 2001 From: x-mass <36629999+x-mass@users.noreply.github.com> Date: Wed, 3 Apr 2024 08:54:30 +0000 Subject: [PATCH 16/23] Refactor Poseidon usage --- .../nil/crypto3/container/merkle/proof.hpp | 46 ++--------- include/nil/crypto3/container/merkle/tree.hpp | 76 +------------------ test/merkle/merkle.cpp | 59 +++++++++++++- 3 files changed, 64 insertions(+), 117 deletions(-) diff --git a/include/nil/crypto3/container/merkle/proof.hpp b/include/nil/crypto3/container/merkle/proof.hpp index 2fd886d575..12c29ab29f 100644 --- a/include/nil/crypto3/container/merkle/proof.hpp +++ b/include/nil/crypto3/container/merkle/proof.hpp @@ -53,7 +53,7 @@ namespace nil { } // namespace marshalling namespace containers { namespace detail { - template + template class merkle_proof_impl { public: typedef NodeType node_type; @@ -127,57 +127,25 @@ namespace nil { } } - // Specilized implementaions below. template - typename std::enable_if_t::value, - bool> validate(const Hashable &a) const { + bool validate(const Hashable &a) const { using hash_type = typename NodeType::hash_type; value_type d = crypto3::hash(a); for (auto &it : _path) { accumulator_set acc; size_t i = 0; for (; (i < arity - 1) && i == it[i]._position; ++i) { - crypto3::hash(it[i]._hash.begin(), it[i]._hash.end(), acc); + crypto3::hash(it[i]._hash, acc); } - crypto3::hash(d.begin(), d.end(), acc); + crypto3::hash(d, acc); for (; i < arity - 1; ++i) { - crypto3::hash(it[i]._hash.begin(), it[i]._hash.end(), acc); + crypto3::hash(it[i]._hash, acc); } d = accumulators::extract::hash(acc); } return (d == _root); } - // Specialize for poseidon. - template - typename std::enable_if_t::value, bool> - validate(const Hashable &a) const { - BOOST_ASSERT_MSG(Arity == 2, "Poseidon is only supported for arity 2"); - - typedef NodeType node_type; - typedef typename node_type::hash_type hash_type; - - constexpr static const std::size_t arity = Arity; - - constexpr static const std::size_t value_bits = node_type::value_bits; - typedef typename node_type::value_type value_type; - - value_type d = generate_poseidon_leaf_hash(a);// crypto3::hash(a); - for (auto &it : _path) { - std::vector values; - size_t i = 0; - for (; (i < arity - 1) && i == it[i]._position; ++i) { - values.push_back(it[i]._hash); - } - values.push_back(d); - for (; i < arity - 1; ++i) { - values.push_back(it[i]._hash); - } - d = generate_poseidon_hash(values[0], values[1]); - } - return (d == _root); - } - static std::vector generate_compressed_proofs(const containers::merkle_tree &tree, std::vector leaf_idxs) { @@ -261,11 +229,11 @@ namespace nil { accumulator_set acc; std::size_t i = 0; for (; (i < Arity - 1) && i == it[i].position(); ++i) { - crypto3::hash(it[i].hash().begin(), it[i].hash().end(), acc); + crypto3::hash(it[i].hash(), acc); } crypto3::hash(d.begin(), d.end(), acc); for (; i < Arity - 1; ++i) { - crypto3::hash(it[i].hash().begin(), it[i].hash().end(), acc); + crypto3::hash(it[i].hash(), acc); } d = accumulators::extract::hash(acc); hashes.push_back(d); diff --git a/include/nil/crypto3/container/merkle/tree.hpp b/include/nil/crypto3/container/merkle/tree.hpp index d139849fbf..ac284a0728 100644 --- a/include/nil/crypto3/container/merkle/tree.hpp +++ b/include/nil/crypto3/container/merkle/tree.hpp @@ -37,9 +37,6 @@ #include #include -#include -#include -#include #include #include @@ -484,78 +481,7 @@ namespace nil { return accumulators::extract::hash(acc); } - template::value, bool> = true> - typename T::digest_type generate_poseidon_hash(typename T::digest_type first, typename T::digest_type second) { - using field_type = nil::crypto3::algebra::curves::pallas::base_field_type; - using poseidon_policy = nil::crypto3::hashes::detail::mina_poseidon_policy; - hashes::detail::poseidon_sponge_construction sponge; - sponge.absorb(first); - sponge.absorb(second); - return sponge.squeeze(); - } - - template, - std::enable_if_t::value, bool> = true> - typename T::digest_type generate_poseidon_leaf_hash(const LeafData &leaf) { - using field_type = nil::crypto3::algebra::curves::pallas::base_field_type; - using poseidon_policy = nil::crypto3::hashes::detail::mina_poseidon_policy; - hashes::detail::poseidon_sponge_construction sponge; - BOOST_ASSERT_MSG(leaf.size() % 64 == 0, "Leaf size must be a multiple of 64"); - for (std::size_t i = 0; i < leaf.size(); i += 64) { - nil::crypto3::multiprecision::cpp_int first = 0; - std::size_t j = 0; - for(; j < 32; j++){ - first <<= 8; - first += leaf[i + j]; - } - nil::crypto3::multiprecision::cpp_int second = 0; - for(; j < 64; j++){ - second <<= 8; - second += leaf[i + j]; - } - sponge.absorb(first); - sponge.absorb(second); - } - return sponge.squeeze(); - } - - template::value, bool> = true - > - merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { - BOOST_ASSERT_MSG(Arity == 2, "Only arity 2 is supported for poseidon hash function"); - typedef T node_type; - typedef typename node_type::hash_type hash_type; - typedef typename node_type::value_type value_type; - typedef typename std::iterator_traits::value_type leaf_value_type; - - merkle_tree_impl ret(std::distance(first, last)); - - ret.resize(ret.complete_size()); - - nil::crypto3::parallel_transform(first, last, ret.begin(), [](const leaf_value_type& leaf) { - return static_cast(generate_poseidon_leaf_hash(leaf)); - }); - - std::size_t row_idx = ret.leaves(), row_size = row_idx / Arity; - typename merkle_tree_impl::iterator it = ret.begin(); - - std::size_t next_row_start_index = std::distance(first, last); - - for (size_t row_number = 1; row_number < ret.row_count(); ++row_number, row_size /= Arity) { - nil::crypto3::parallel_for(0, row_size, [&ret, it, next_row_start_index](std::size_t index) { - ret[next_row_start_index + index] = generate_poseidon_hash( - *(it + index * Arity), *(it + index * Arity + 1)); - }); - next_row_start_index += row_size; - it += row_size * Arity; - } - return ret; - } - - template::value, bool> = true> + template merkle_tree_impl make_merkle_tree(LeafIterator first, LeafIterator last) { typedef T node_type; typedef typename node_type::hash_type hash_type; diff --git a/test/merkle/merkle.cpp b/test/merkle/merkle.cpp index 3282e9ec7e..96953a7210 100644 --- a/test/merkle/merkle.cpp +++ b/test/merkle/merkle.cpp @@ -26,6 +26,9 @@ #define BOOST_TEST_MODULE containter_merkletree_test +#include +#include +#include #include #include #include @@ -62,6 +65,19 @@ typename std::enable_if::value, std::vector +typename std::enable_if::value, std::vector>>::type + generate_random_data(std::size_t leaf_number) { + std::vector> v; + for (std::size_t i = 0; i < leaf_number; ++i) { + std::array leaf {}; + std::generate(std::begin(leaf), std::end(leaf), + [&]() { return algebra::random_element(); }); + v.emplace_back(leaf); + } + return v; +} + template void testing_validate_template_random_data(std::size_t leaf_number) { std::array data_not_in_tree = {0}; @@ -242,6 +258,7 @@ BOOST_AUTO_TEST_SUITE(containers_merkltree_test) using curve_type = algebra::curves::pallas; using field_type = typename curve_type::base_field_type; using poseidon_type = hashes::poseidon>; +using original_poseidon_type = hashes::original_poseidon>; BOOST_AUTO_TEST_CASE(merkletree_construct_test_1) { std::vector> v = {{'0'}, {'1'}, {'2'}, {'3'}, {'4'}, {'5'}, {'6'}, {'7'}}; @@ -267,13 +284,39 @@ BOOST_AUTO_TEST_CASE(merkletree_validate_test_1) { testing_validate_template, 2>(v); testing_validate_template(v); testing_validate_template, 2>(v); - testing_validate_template(v); + + BOOST_STATIC_ASSERT_MSG(algebra::is_field_element::value, "Expecting Poseidon to consume field elements"); + std::vector> v_field = { + {0x0_cppui255}, + {0x1_cppui255}, + {0x2_cppui255}, + {0x3_cppui255}, + {0x4_cppui255}, + {0x5_cppui255}, + {0x6_cppui255}, + {0x7_cppui255} + }; + testing_validate_template(v_field); + testing_validate_template(v_field); + // When you have bytes input, use wrapper to lazy convert it to field elements: + std::vector< + nil::crypto3::hashes::block_to_field_elements_wrapper< + typename poseidon_type::word_type::field_type, + std::array + > + > wrappers; + for (const auto& inner_containers : v) { + wrappers.emplace_back(inner_containers); + } + testing_validate_template(wrappers); + testing_validate_template(wrappers); std::size_t leaf_number = 8; testing_validate_template_random_data, 2, std::uint8_t, 1>(leaf_number); testing_validate_template_random_data(leaf_number); testing_validate_template_random_data, 2, std::uint8_t, 1>(leaf_number); - testing_validate_template_random_data(leaf_number); + testing_validate_template_random_data(leaf_number); + testing_validate_template_random_data(leaf_number); } BOOST_AUTO_TEST_CASE(merkletree_validate_test_2) { @@ -333,7 +376,17 @@ BOOST_AUTO_TEST_CASE(merkletree_hash_test_1) { "0123456789012345678901234567890123456789012345678901234567890123", "0123456789012345678901234567890123456789012345678901234567890123" }; - merkle_tree tree = make_merkle_tree(v_64.begin(), v_64.end()); + std::vector< + nil::crypto3::hashes::block_to_field_elements_wrapper< + typename poseidon_type::word_type::field_type, + std::string, + /*OverflowOnPurpose=*/ true + > + > wrappers; + for (const auto& inner_containers : v_64) { + wrappers.emplace_back(inner_containers); + } + merkle_tree tree = make_merkle_tree(wrappers.begin(), wrappers.end()); BOOST_CHECK(tree.root() == 0x6E7641F1EAE17C0DA8227840EFEA6E1D17FB5EBA600D9DC34F314D5400E5BF3_cppui255); } From c5d110829353d3e08beaedb0c8988cbc05aacafb Mon Sep 17 00:00:00 2001 From: Martun Karapetyan Date: Thu, 16 May 2024 11:53:23 +0400 Subject: [PATCH 17/23] Fix merkle tree test. (#30) --- test/merkle/merkle.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/merkle/merkle.cpp b/test/merkle/merkle.cpp index 96953a7210..f3d8dc2d5d 100644 --- a/test/merkle/merkle.cpp +++ b/test/merkle/merkle.cpp @@ -80,7 +80,7 @@ typename std::enable_if::value, std::vector template void testing_validate_template_random_data(std::size_t leaf_number) { - std::array data_not_in_tree = {0}; + std::array data_not_in_tree = {0u}; auto data = generate_random_data(leaf_number); auto tree = make_merkle_tree(data.begin(), data.end()); @@ -287,14 +287,14 @@ BOOST_AUTO_TEST_CASE(merkletree_validate_test_1) { BOOST_STATIC_ASSERT_MSG(algebra::is_field_element::value, "Expecting Poseidon to consume field elements"); std::vector> v_field = { - {0x0_cppui255}, - {0x1_cppui255}, - {0x2_cppui255}, - {0x3_cppui255}, - {0x4_cppui255}, - {0x5_cppui255}, - {0x6_cppui255}, - {0x7_cppui255} + {0x0_cppui_modular255}, + {0x1_cppui_modular255}, + {0x2_cppui_modular255}, + {0x3_cppui_modular255}, + {0x4_cppui_modular255}, + {0x5_cppui_modular255}, + {0x6_cppui_modular255}, + {0x7_cppui_modular255} }; testing_validate_template(v_field); testing_validate_template(v_field); @@ -387,7 +387,7 @@ BOOST_AUTO_TEST_CASE(merkletree_hash_test_1) { wrappers.emplace_back(inner_containers); } merkle_tree tree = make_merkle_tree(wrappers.begin(), wrappers.end()); - BOOST_CHECK(tree.root() == 0x6E7641F1EAE17C0DA8227840EFEA6E1D17FB5EBA600D9DC34F314D5400E5BF3_cppui255); + BOOST_CHECK(tree.root() == 0x6E7641F1EAE17C0DA8227840EFEA6E1D17FB5EBA600D9DC34F314D5400E5BF3_cppui_modular255); } BOOST_AUTO_TEST_CASE(merkletree_hash_test_2) { From 2929f4e9054b220ad8821d23a5b58761366a71ff Mon Sep 17 00:00:00 2001 From: Martun Karapetyan Date: Thu, 16 May 2024 12:51:47 +0400 Subject: [PATCH 18/23] Set constexpr step limit to a large number. (#31) --- test/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 25975dacf0..be92abaa9f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -72,6 +72,13 @@ macro(define_storage_test test) elseif(target_type STREQUAL "STATIC_LIB") endif() + + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(${target_name} PRIVATE "-fconstexpr-steps=2147483647" "-ftemplate-backtrace-limit=0") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${target_name} PRIVATE "-fconstexpr-ops-limit=4294967295" "-ftemplate-backtrace-limit=0") + endif() + endmacro() set(TESTS_NAMES From 6f1b1c52fe46c1ba41fab1737500177d8265dce3 Mon Sep 17 00:00:00 2001 From: MALASHKIN Andrei Date: Mon, 20 May 2024 10:10:21 +0200 Subject: [PATCH 19/23] cleanup cmake --- .gitmodules | 3 - CMakeLists.txt | 11 +- cmake/modules/.gitattributes | 3 - cmake/modules/.travis.yml | 50 --- cmake/modules/CMakeLists.txt | 7 - cmake/modules/README.md | 29 -- cmake/modules/appveyor.yml | 38 -- cmake/modules/doc/conf.py | 333 ------------------ cmake/modules/doc/index.rst | 14 - cmake/modules/doc/make.bat | 281 --------------- cmake/modules/doc/requirements.txt | 2 - cmake/modules/doc/src/Building.rst | 319 ----------------- cmake/modules/doc/src/CMDeploy.rst | 28 -- cmake/modules/doc/src/CMExport.rst | 31 -- cmake/modules/doc/src/CMIgnorePackage.rst | 15 - cmake/modules/doc/src/CMInstallTargets.rst | 25 -- cmake/modules/doc/src/CMPkgConfig.rst | 59 ---- cmake/modules/doc/src/CMProperties.rst | 65 ---- cmake/modules/doc/src/CMSetupVersion.rst | 33 -- cmake/modules/doc/src/CMTest.rst | 89 ----- cmake/modules/doc/src/Intro.rst | 89 ----- cmake/modules/doc/src/Modules.rst | 15 - .../share/modules/cmake/CMConfig.cmake | 144 -------- .../share/modules/cmake/CMDeploy.cmake | 48 --- .../share/modules/cmake/CMExport.cmake | 147 -------- .../share/modules/cmake/CMFuture.cmake | 87 ----- .../share/modules/cmake/CMIgnorePackage.cmake | 6 - .../modules/cmake/CMInstallTargets.cmake | 43 --- .../share/modules/cmake/CMPkgConfig.cmake | 250 ------------- .../share/modules/cmake/CMProperties.cmake | 98 ------ .../share/modules/cmake/CMSetupVersion.cmake | 52 --- .../modules/share/modules/cmake/CMTest.cmake | 232 ------------ .../share/modules/cmake/CMToSnakeCase.cmake | 11 - cmake/modules/share/modules/cmake/version.hpp | 10 - cmake/modules/test/CMakeLists.txt | 43 --- cmake/modules/test/basicapp/CMakeLists.txt | 21 -- cmake/modules/test/basicapp/main.cpp | 6 - cmake/modules/test/checkprop/CMakeLists.txt | 12 - cmake/modules/test/fail/simple-test.cmake | 1 - .../test/findpackagecheck/CMakeLists.txt | 15 - .../modules/test/findpackagecheck/main.cpp.in | 4 - cmake/modules/test/libbasic/CMakeLists.txt | 21 -- cmake/modules/test/libbasic/main.cpp | 6 - cmake/modules/test/libbasic/test.cpp | 2 - .../test/libbasicnamespace/CMakeLists.txt | 21 -- cmake/modules/test/libbasicnamespace/main.cpp | 5 - cmake/modules/test/libbasicnamespace/test.cpp | 2 - cmake/modules/test/libsimple/CMakeLists.txt | 51 --- cmake/modules/test/libsimple/compiletest.cpp | 7 - .../test/libsimple/compiletestwillfail.cpp | 6 - cmake/modules/test/libsimple/include/simple.h | 22 -- cmake/modules/test/libsimple/test.cpp | 5 - cmake/modules/test/libsimple/testwillfail.cpp | 6 - .../test/libsimplecustomname/CMakeLists.txt | 29 -- .../test/libsimplecustomname/compiletest.cpp | 7 - .../test/libsimplecustomname/include/simple.h | 8 - .../modules/test/libsimplecustomname/test.cpp | 5 - .../test/libsimplenamespace/CMakeLists.txt | 28 -- .../test/libsimplenamespace/compiletest.cpp | 7 - .../test/libsimplenamespace/include/simple.h | 12 - .../modules/test/libsimplenamespace/test.cpp | 5 - .../modules/test/parseversion/CMakeLists.txt | 32 -- .../modules/test/parseversion/compiletest.cpp | 7 - .../test/parseversion/include/simple.h | 10 - .../test/parseversion/include/version.h | 8 - cmake/modules/test/parseversion/test.cpp | 5 - cmake/modules/test/pass/basic.cmake | 6 - .../modules/test/pass/defaultproperties.cmake | 15 - cmake/modules/test/pass/parseversion.cmake | 1 - cmake/modules/test/pass/properties.cmake | 1 - cmake/modules/test/pass/simple-shared.cmake | 4 - .../modules/test/pass/simple-test-build.cmake | 3 - .../test/pass/simple-test-shared.cmake | 3 - cmake/modules/test/pass/simple-test.cmake | 3 - cmake/modules/test/pass/simple.cmake | 4 - .../modules/test/pass/simplecustomname.cmake | 2 - cmake/modules/test/pass/simplenamespace.cmake | 2 - cmake/modules/test/pass/superproject.cmake | 5 - .../test/pkgconfigcheck/CMakeLists.txt | 46 --- cmake/modules/test/properties/CMakeLists.txt | 67 ---- .../modules/test/properties/include/simple.h | 8 - cmake/modules/test/properties/nowarnings.cpp | 5 - cmake/modules/test/properties/rtti.cpp | 20 -- cmake/modules/test/properties/test.cpp | 5 - cmake/modules/test/properties/throw.cpp | 6 - cmake/modules/test/properties/warnings.cpp | 9 - cmake/modules/test/simpletest/CMakeLists.txt | 26 -- .../modules/test/simpletest/include/simple.h | 1 - cmake/modules/test/simpletest/simple.cpp | 4 - cmake/modules/test/simpletest/test.cpp | 5 - .../test/simpletest/test/CMakeLists.txt | 7 - cmake/modules/test/simpletest/test/test.cpp | 5 - .../modules/test/superproject/CMakeLists.txt | 10 - cmake/modules/test/test.cmake | 124 ------- test/CMakeLists.txt | 2 +- 95 files changed, 2 insertions(+), 3483 deletions(-) delete mode 100644 .gitmodules delete mode 100644 cmake/modules/.gitattributes delete mode 100644 cmake/modules/.travis.yml delete mode 100644 cmake/modules/CMakeLists.txt delete mode 100644 cmake/modules/README.md delete mode 100644 cmake/modules/appveyor.yml delete mode 100644 cmake/modules/doc/conf.py delete mode 100644 cmake/modules/doc/index.rst delete mode 100644 cmake/modules/doc/make.bat delete mode 100644 cmake/modules/doc/requirements.txt delete mode 100644 cmake/modules/doc/src/Building.rst delete mode 100644 cmake/modules/doc/src/CMDeploy.rst delete mode 100644 cmake/modules/doc/src/CMExport.rst delete mode 100644 cmake/modules/doc/src/CMIgnorePackage.rst delete mode 100644 cmake/modules/doc/src/CMInstallTargets.rst delete mode 100644 cmake/modules/doc/src/CMPkgConfig.rst delete mode 100644 cmake/modules/doc/src/CMProperties.rst delete mode 100644 cmake/modules/doc/src/CMSetupVersion.rst delete mode 100644 cmake/modules/doc/src/CMTest.rst delete mode 100644 cmake/modules/doc/src/Intro.rst delete mode 100644 cmake/modules/doc/src/Modules.rst delete mode 100644 cmake/modules/share/modules/cmake/CMConfig.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMDeploy.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMExport.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMFuture.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMIgnorePackage.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMInstallTargets.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMPkgConfig.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMProperties.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMSetupVersion.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMTest.cmake delete mode 100644 cmake/modules/share/modules/cmake/CMToSnakeCase.cmake delete mode 100644 cmake/modules/share/modules/cmake/version.hpp delete mode 100644 cmake/modules/test/CMakeLists.txt delete mode 100644 cmake/modules/test/basicapp/CMakeLists.txt delete mode 100644 cmake/modules/test/basicapp/main.cpp delete mode 100644 cmake/modules/test/checkprop/CMakeLists.txt delete mode 100644 cmake/modules/test/fail/simple-test.cmake delete mode 100644 cmake/modules/test/findpackagecheck/CMakeLists.txt delete mode 100644 cmake/modules/test/findpackagecheck/main.cpp.in delete mode 100644 cmake/modules/test/libbasic/CMakeLists.txt delete mode 100644 cmake/modules/test/libbasic/main.cpp delete mode 100644 cmake/modules/test/libbasic/test.cpp delete mode 100644 cmake/modules/test/libbasicnamespace/CMakeLists.txt delete mode 100644 cmake/modules/test/libbasicnamespace/main.cpp delete mode 100644 cmake/modules/test/libbasicnamespace/test.cpp delete mode 100644 cmake/modules/test/libsimple/CMakeLists.txt delete mode 100644 cmake/modules/test/libsimple/compiletest.cpp delete mode 100644 cmake/modules/test/libsimple/compiletestwillfail.cpp delete mode 100644 cmake/modules/test/libsimple/include/simple.h delete mode 100644 cmake/modules/test/libsimple/test.cpp delete mode 100644 cmake/modules/test/libsimple/testwillfail.cpp delete mode 100644 cmake/modules/test/libsimplecustomname/CMakeLists.txt delete mode 100644 cmake/modules/test/libsimplecustomname/compiletest.cpp delete mode 100644 cmake/modules/test/libsimplecustomname/include/simple.h delete mode 100644 cmake/modules/test/libsimplecustomname/test.cpp delete mode 100644 cmake/modules/test/libsimplenamespace/CMakeLists.txt delete mode 100644 cmake/modules/test/libsimplenamespace/compiletest.cpp delete mode 100644 cmake/modules/test/libsimplenamespace/include/simple.h delete mode 100644 cmake/modules/test/libsimplenamespace/test.cpp delete mode 100644 cmake/modules/test/parseversion/CMakeLists.txt delete mode 100644 cmake/modules/test/parseversion/compiletest.cpp delete mode 100644 cmake/modules/test/parseversion/include/simple.h delete mode 100644 cmake/modules/test/parseversion/include/version.h delete mode 100644 cmake/modules/test/parseversion/test.cpp delete mode 100644 cmake/modules/test/pass/basic.cmake delete mode 100644 cmake/modules/test/pass/defaultproperties.cmake delete mode 100644 cmake/modules/test/pass/parseversion.cmake delete mode 100644 cmake/modules/test/pass/properties.cmake delete mode 100644 cmake/modules/test/pass/simple-shared.cmake delete mode 100644 cmake/modules/test/pass/simple-test-build.cmake delete mode 100644 cmake/modules/test/pass/simple-test-shared.cmake delete mode 100644 cmake/modules/test/pass/simple-test.cmake delete mode 100644 cmake/modules/test/pass/simple.cmake delete mode 100644 cmake/modules/test/pass/simplecustomname.cmake delete mode 100644 cmake/modules/test/pass/simplenamespace.cmake delete mode 100644 cmake/modules/test/pass/superproject.cmake delete mode 100644 cmake/modules/test/pkgconfigcheck/CMakeLists.txt delete mode 100644 cmake/modules/test/properties/CMakeLists.txt delete mode 100644 cmake/modules/test/properties/include/simple.h delete mode 100644 cmake/modules/test/properties/nowarnings.cpp delete mode 100644 cmake/modules/test/properties/rtti.cpp delete mode 100644 cmake/modules/test/properties/test.cpp delete mode 100644 cmake/modules/test/properties/throw.cpp delete mode 100644 cmake/modules/test/properties/warnings.cpp delete mode 100644 cmake/modules/test/simpletest/CMakeLists.txt delete mode 100644 cmake/modules/test/simpletest/include/simple.h delete mode 100644 cmake/modules/test/simpletest/simple.cpp delete mode 100644 cmake/modules/test/simpletest/test.cpp delete mode 100644 cmake/modules/test/simpletest/test/CMakeLists.txt delete mode 100644 cmake/modules/test/simpletest/test/test.cpp delete mode 100644 cmake/modules/test/superproject/CMakeLists.txt delete mode 100644 cmake/modules/test/test.cmake diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 9373da4a58..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "cmake/modules"] - path = cmake/modules - url = https://github.com/NilFoundation/actor-containers.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b0b7396fa..a845938647 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,20 +39,11 @@ include(CMSetupVersion) cm_workspace(actor) -macro(cm_find_package NAME) - if (NOT "${NAME}" MATCHES "^${CMAKE_WORKSPACE_NAME}_.*$" AND NOT "${NAME}" STREQUAL CM) - find_package(${ARGV}) - else () - set(${ARGV0}_FOUND ON CACHE BOOL "") - endif () -endmacro() - -cm_find_package(CM) include(CMDeploy) include(CMSetupVersion) if (NOT Boost_FOUND AND NOT CMAKE_CROSSCOMPILING) - cm_find_package(Boost COMPONENTS REQUIRED filesystem) + find_package(Boost COMPONENTS REQUIRED filesystem) endif () cm_project(containers WORKSPACE_NAME ${CMAKE_WORKSPACE_NAME}) diff --git a/cmake/modules/.gitattributes b/cmake/modules/.gitattributes deleted file mode 100644 index 1c9df89903..0000000000 --- a/cmake/modules/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -* text=auto -*.bat text eol=crlf -Makefile text eol=lf diff --git a/cmake/modules/.travis.yml b/cmake/modules/.travis.yml deleted file mode 100644 index fe2afb47df..0000000000 --- a/cmake/modules/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -sudo: required -dist: trusty -language: cpp -script: cmake - -matrix: - include: - # OSX - - os: osx - compiler: clang - - - os: linux - compiler: gcc - addons: &gcc - apt: - packages: - - util-linux - - g++-4.9 - sources: - - ubuntu-toolchain-r-test - -install: - - export CHECKOUT_PATH=`pwd` - # Setup deps directory - - export DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - - mkdir ${DEPS_DIR} && cd ${DEPS_DIR} - - mkdir usr - - export PATH=${DEPS_DIR}/usr/bin:${PATH} - # Install cmake - - CMAKE_URL="http://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz" - - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C usr; fi - # Show compiler info - - $CXX --version - - which $CXX - - $CC --version - - which $CC - - which cmake - - cmake --version - -script: - - export INSTALL_PREFIX_PATH="${TRAVIS_BUILD_DIR}/usr" - - mkdir -p "$INSTALL_PREFIX_PATH" - - cd $CHECKOUT_PATH - - mkdir build - - cd build - - cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX_PATH .. - - make check - - make install - - rm -rf "$INSTALL_PREFIX_PATH" - diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt deleted file mode 100644 index b0b03fa21c..0000000000 --- a/cmake/modules/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required (VERSION 3.5) - -install(DIRECTORY share/modules/cmake DESTINATION cm) - -enable_testing() -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR}) -add_subdirectory(test) diff --git a/cmake/modules/README.md b/cmake/modules/README.md deleted file mode 100644 index 07b26b29ac..0000000000 --- a/cmake/modules/README.md +++ /dev/null @@ -1,29 +0,0 @@ -CMake Modules -============= -[![Build Status](https://travis-ci.com/BoostCMake/cmake_modules.svg?branch=master)](https://travis-ci.com/BoostCMake/cmake_modules) [![Build status](https://ci.appveyor.com/api/projects/status/f3qe31c4hd7iwumn/branch/master?svg=true)](https://ci.appveyor.com/project/nemo1369/cmake-modules/branch/master) - -Motivation ----------- - -This provides cmake modules suitable for in-project and in-repository dependencies management. It provides modules to reduce the boilerplate for installing, versioning, setting up package config, and creating tests. - -Usage ------ - -The modules can be installed using standard cmake install: - - mkdir build - cd build - cmake .. - cmake --build . --target install - -Once installed, the modules can be used by using `find_package` and then including the appropriate module: - - find_package(CM) - include(CMPackage) - -Documentation -------------- - -http://bcm.readthedocs.io - diff --git a/cmake/modules/appveyor.yml b/cmake/modules/appveyor.yml deleted file mode 100644 index 4b061b7aa3..0000000000 --- a/cmake/modules/appveyor.yml +++ /dev/null @@ -1,38 +0,0 @@ - -os: Visual Studio 2015 - -environment: - matrix: - # - GENERATOR: "Visual Studio 14 2015 Win64" - # CONFIG: Debug - - # - GENERATOR: "Visual Studio 14 2015 Win64" - # CONFIG: Release - - - GENERATOR: "Visual Studio 14 2015" - CONFIG: Debug - - # - GENERATOR: "Visual Studio 14 2015" - # CONFIG: Release - -matrix: - fast_finish: true - -install: - # Install pkg-config from chocolatey - - cinst pkgconfiglite - -build_script: - - cmd: set PATH=C:\Program Files (x86)\CMake\bin;%PATH% - - cmd: set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH% - - cmd: call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat" - - cmd: set CTEST_OUTPUT_ON_FAILURE=1 - - cmd: cmake --version - - cmd: mkdir build - - cmd: cd build - - cmd: cmake .. -G"%GENERATOR%" - - cmd: cmake --build . --config %CONFIG% --target check - -# test_script: -# - cmd: ctest -C Debug --output-on-failure -# - cmd: cd ../../ \ No newline at end of file diff --git a/cmake/modules/doc/conf.py b/cmake/modules/doc/conf.py deleted file mode 100644 index eaeee30c0a..0000000000 --- a/cmake/modules/doc/conf.py +++ /dev/null @@ -1,333 +0,0 @@ -# -*- coding: utf-8 -*- -# -# modules documentation build configuration file, created by -# sphinx-quickstart on Tue Jan 10 00:08:48 2017. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) -import sphinx_boost - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The encoding of source files. -# -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'modules' -copyright = u'2017, Paul Fultz II' -author = u'Paul Fultz II' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = u'0.1' -# The full version, including alpha/beta/rc tags. -release = u'0.1' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# -# today = '' -# -# Else, today_fmt is used as the format for a strftime call. -# -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'tango' - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'boost' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -html_theme_path = [sphinx_boost.get_html_theme_path()] - -# The name for this set of Sphinx documents. -# " v documentation" by default. -# -# html_title = u'modules v0.1' - -# A shorter title for the navigation bar. Default is the same as html_title. -# -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# -html_logo = 'boost-proposed.png' - -# The name of an image file (relative to this directory) to use as a favicon of -# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# -# html_extra_path = [] - -# If not None, a 'Last updated on:' timestamp is inserted at every page -# bottom, using the given strftime format. -# The empty string is equivalent to '%b %d, %Y'. -# -# html_last_updated_fmt = None - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# -# html_additional_pages = {} - -# If false, no module index is generated. -# -# html_domain_indices = True - -# If false, no index is generated. -# -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' -# -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# 'ja' uses this config value. -# 'zh' user can custom change `jieba` dictionary path. -# -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = 'bcmdoc' - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'modules.tex', u'modules Documentation', - u'Paul Fultz II', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# -# latex_use_parts = False - -# If true, show page references after internal links. -# -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# -# latex_appendices = [] - -# If false, no module index is generated. -# -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'modules', u'modules Documentation', - [author], 1) -] - -# If true, show URL addresses after external links. -# -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'modules', u'modules Documentation', - author, 'modules', 'Boost cmake modules', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -# -# texinfo_appendices = [] - -# If false, no module index is generated. -# -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# -# texinfo_no_detailmenu = False diff --git a/cmake/modules/doc/index.rst b/cmake/modules/doc/index.rst deleted file mode 100644 index c223e01120..0000000000 --- a/cmake/modules/doc/index.rst +++ /dev/null @@ -1,14 +0,0 @@ -.. _contents: - -CMakeModules -=== - -**Mikhail Komarov** - -.. toctree:: - :maxdepth: 3 - - src/Intro - src/Building - src/Modules - diff --git a/cmake/modules/doc/make.bat b/cmake/modules/doc/make.bat deleted file mode 100644 index 07e686b6b2..0000000000 --- a/cmake/modules/doc/make.bat +++ /dev/null @@ -1,281 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set BUILDDIR=_build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . -set I18NSPHINXOPTS=%SPHINXOPTS% . -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% - set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - echo. dirhtml to make HTML files named index.html in directories - echo. singlehtml to make a single large HTML file - echo. pickle to make pickle files - echo. json to make JSON files - echo. htmlhelp to make HTML files and a HTML help project - echo. qthelp to make HTML files and a qthelp project - echo. devhelp to make HTML files and a Devhelp project - echo. epub to make an epub - echo. epub3 to make an epub3 - echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - echo. text to make text files - echo. man to make manual pages - echo. texinfo to make Texinfo files - echo. gettext to make PO message catalogs - echo. changes to make an overview over all changed/added/deprecated items - echo. xml to make Docutils-native XML files - echo. pseudoxml to make pseudoxml-XML files for display purposes - echo. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in the documentation if enabled - echo. coverage to run coverage check of the documentation if enabled - echo. dummy to check syntax errors of document sources - goto end -) - -if "%1" == "clean" ( - for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i - del /q /s %BUILDDIR%\* - goto end -) - - -REM Check if sphinx-build is available and fallback to Python version if any -%SPHINXBUILD% 1>NUL 2>NUL -if errorlevel 9009 goto sphinx_python -goto sphinx_ok - -:sphinx_python - -set SPHINXBUILD=python -m sphinx.__init__ -%SPHINXBUILD% 2> nul -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -:sphinx_ok - - -if "%1" == "html" ( - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. - goto end -) - -if "%1" == "dirhtml" ( - %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. - goto end -) - -if "%1" == "singlehtml" ( - %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. - goto end -) - -if "%1" == "pickle" ( - %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the pickle files. - goto end -) - -if "%1" == "json" ( - %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the JSON files. - goto end -) - -if "%1" == "htmlhelp" ( - %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in %BUILDDIR%/htmlhelp. - goto end -) - -if "%1" == "qthelp" ( - %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\bcm.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\bcm.ghc - goto end -) - -if "%1" == "devhelp" ( - %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. - goto end -) - -if "%1" == "epub" ( - %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The epub file is in %BUILDDIR%/epub. - goto end -) - -if "%1" == "epub3" ( - %SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3 - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The epub3 file is in %BUILDDIR%/epub3. - goto end -) - -if "%1" == "latex" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdf" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf - cd %~dp0 - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "latexpdfja" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - cd %BUILDDIR%/latex - make all-pdf-ja - cd %~dp0 - echo. - echo.Build finished; the PDF files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "text" ( - %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The text files are in %BUILDDIR%/text. - goto end -) - -if "%1" == "man" ( - %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The manual pages are in %BUILDDIR%/man. - goto end -) - -if "%1" == "texinfo" ( - %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. - goto end -) - -if "%1" == "gettext" ( - %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The message catalogs are in %BUILDDIR%/locale. - goto end -) - -if "%1" == "changes" ( - %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes - if errorlevel 1 exit /b 1 - echo. - echo.The overview file is in %BUILDDIR%/changes. - goto end -) - -if "%1" == "linkcheck" ( - %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck - if errorlevel 1 exit /b 1 - echo. - echo.Link check complete; look for any errors in the above output ^ -or in %BUILDDIR%/linkcheck/output.txt. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest - if errorlevel 1 exit /b 1 - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in %BUILDDIR%/doctest/output.txt. - goto end -) - -if "%1" == "coverage" ( - %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage - if errorlevel 1 exit /b 1 - echo. - echo.Testing of coverage in the sources finished, look at the ^ -results in %BUILDDIR%/coverage/python.txt. - goto end -) - -if "%1" == "xml" ( - %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The XML files are in %BUILDDIR%/xml. - goto end -) - -if "%1" == "pseudoxml" ( - %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. - goto end -) - -if "%1" == "dummy" ( - %SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. Dummy builder generates no files. - goto end -) - -:end diff --git a/cmake/modules/doc/requirements.txt b/cmake/modules/doc/requirements.txt deleted file mode 100644 index 6e052bd53c..0000000000 --- a/cmake/modules/doc/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -sphinx -sphinx-boost>0.0.2 \ No newline at end of file diff --git a/cmake/modules/doc/src/Building.rst b/cmake/modules/doc/src/Building.rst deleted file mode 100644 index 7a9880cc7c..0000000000 --- a/cmake/modules/doc/src/Building.rst +++ /dev/null @@ -1,319 +0,0 @@ -======== -Building -======== - -There are two scenarios where the users will consume their dependencies in the build: - -* Prebuilt binaries using ``find_package`` -* Integrated builds using ``add_subdirectory`` - -When we build libraries using cmake, we want to be able to support both scenarios. - -The first scenario the user would build and install each dependency. With this scenario, we need to generate usage requirements that can be consumed by the user, and ultimately this is done through cmake's ``find_package`` mechanism. - -In the integrated build scenario, the user adds the sources with ``add_subdirectory``, and then all dependencies are built in the user's build. There is no need to generate usage requirements as the cmake targets are directly available in the build. - -Let's first look at standalone build. - ------------------------------- -Building standalone with cmake ------------------------------- - -Let's look at building a library like Boost.Filesystem using just cmake. When we start a cmake, we start with minimuim requirement and the project name:: - - cmake_minimum_required(VERSION 3.5) - project(boost_filesystem) - -Then we can define the library and the sources it will build:: - - add_library(boost_filesystem - src/operations.cpp - src/portability.cpp - src/codecvt_error_category.cpp - src/utf8_codecvt_facet.cpp - src/windows_file_codecvt.cpp - src/unique_path.cpp - src/path.cpp - src/path_traits.cpp - ) - -So this will build the library named ``boost_filesystem``, however, we need to supply the dependencies to ``boost_filesystem`` and add the include directories. To add the include directory we use ``target_include_directories``. For this, we tell cmake to use local ``include`` directory, but since this is only valid during build and not after installation, we use the ``BUILD_INTERFACE`` generator expression so that cmake will only use it during build and not installation:: - - target_include_directories(boost_filesystem PUBLIC - $ - ) - -Using ``PUBLIC`` means this include directory will be used internally to build, and downstream users need this include as well. Next, we need to pull in the dependencies. To do this, we call ``find_package``, and for the sake of the turtorial we assume that the upstream boost libraries have already set this up:: - - find_package(boost_core) - find_package(boost_static_assert) - find_package(boost_iterator) - find_package(boost_detail) - find_package(boost_system) - find_package(boost_functional) - find_package(boost_assert) - find_package(boost_range) - find_package(boost_type_traits) - find_package(boost_smart_ptr) - find_package(boost_io) - find_package(boost_config) - -Calling ``find_package`` will find those libraries and provide a target we can use to link against. The next step is to link it using ``target_link_libraries``:: - - target_link_libraries(boost_filesystem PUBLIC - boost::core - boost::static_assert - boost::iterator - boost::detail - boost::system - boost::functional - boost::assert - boost::range - boost::type_traits - boost::smart_ptr - boost::io - boost::config - ) - -Now, some of these libraries are header-only, but when we call ``target_link_libraries`` it will add all the flags necessary to use those libraries. Next step is installation, using the ``install`` command:: - - install(DIRECTORY include/ DESTINATION include) - - install(TARGETS boost_filesystem EXPORT boost_filesystem-targets - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - INCLUDES DESTINATION include - ) - -So this will install the include directories and install the library. The ``EXPORT`` command will have cmake generate an export file that will create the target's usage requirements in cmake. This will enable the target to be used by downstream libraries, just like we used ```boost::system``. However, this will only tells cmake which targets are in the export file. To generate it we use ``install(EXPORT)``:: - - install(EXPORT boost_filesystem-targets - FILE boost_filesystem-targets.cmake - NAMESPACE boost:: - DESTINATION lib/cmake/boost_filesystem - ) - -This sets a namespace ``boost::`` on the target, but our target is named ``boost_filesystem``, and we want the exported target to be ``boost::filesystem`` not ``boost::boost_filesystem``. We can do that by setting the export name:: - - set_property(TARGET boost_filesystem PROPERTY EXPORT_NAME filesystem) - -We can also define a target alias to ``boost::filesystem``, which helps integrated builds:: - - add_library(boost::filesystem ALIAS boost_filesystem) - -So now have exported targets we want to generate a ``boost_filesystem-config.cmake`` file so it can be used with ``find_package(boost_filesystem)``. To do this we generate a file the includes the export file, but it also calls ``find_dependency`` on each dependency so that the user does not have to call it:: - - file(WRITE "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" " - include(CMakeFindDependencyMacro) - find_dependency(boost_core) - find_dependency(boost_static_assert) - find_dependency(boost_iterator) - find_dependency(boost_detail) - find_dependency(boost_system) - find_dependency(boost_functional) - find_dependency(boost_assert) - find_dependency(boost_range) - find_dependency(boost_type_traits) - find_dependency(boost_smart_ptr) - find_dependency(boost_io) - find_dependency(boost_config) - include(\"\${CMAKE_CURRENT_LIST_DIR}/boost_filesystem-targets.cmake\") - ") - -Besides the ``boost_filesystem-config.cmake``, we also need a version file to check compatibility. This can be done using cmake's ``write_basic_package_version_file`` function:: - - write_basic_package_version_file("${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" - VERSION 1.64 - COMPATIBILITY AnyNewerVersion - ) - -Then finally we install these files:: - - install(FILES - "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" - "${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" - DESTINATION lib/cmake/boost_filesystem - ) - -Putting it all together we have a cmake file that looks like this:: - - cmake_minimum_required(VERSION 3.5) - project(boost_filesystem) - include(CMakePackageConfigHelpers) - - find_package(boost_core) - find_package(boost_static_assert) - find_package(boost_iterator) - find_package(boost_detail) - find_package(boost_system) - find_package(boost_functional) - find_package(boost_assert) - find_package(boost_range) - find_package(boost_type_traits) - find_package(boost_smart_ptr) - find_package(boost_io) - find_package(boost_config) - - add_library(boost_filesystem - src/operations.cpp - src/portability.cpp - src/codecvt_error_category.cpp - src/utf8_codecvt_facet.cpp - src/windows_file_codecvt.cpp - src/unique_path.cpp - src/path.cpp - src/path_traits.cpp - ) - add_library(boost::filesystem ALIAS boost_filesystem) - set_property(TARGET boost_filesystem PROPERTY EXPORT_NAME filesystem) - - target_include_directories(boost_filesystem PUBLIC - $ - ) - target_link_libraries(boost_filesystem PUBLIC - boost::core - boost::static_assert - boost::iterator - boost::detail - boost::system - boost::functional - boost::assert - boost::range - boost::type_traits - boost::smart_ptr - boost::io - boost::config - ) - - - install(DIRECTORY include/ DESTINATION include) - - install(TARGETS boost_filesystem EXPORT boost_filesystem-targets - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - INCLUDES DESTINATION include - ) - - install(EXPORT boost_filesystem-targets - FILE boost_filesystem-targets.cmake - NAMESPACE boost:: - DESTINATION lib/cmake/boost_filesystem - ) - - file(WRITE "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" " - include(CMakeFindDependencyMacro) - find_dependency(boost_core) - find_dependency(boost_static_assert) - find_dependency(boost_iterator) - find_dependency(boost_detail) - find_dependency(boost_system) - find_dependency(boost_functional) - find_dependency(boost_assert) - find_dependency(boost_range) - find_dependency(boost_type_traits) - find_dependency(boost_smart_ptr) - find_dependency(boost_io) - find_dependency(boost_config) - include(\"\${CMAKE_CURRENT_LIST_DIR}/boost_filesystem-targets.cmake\") - ") - - write_basic_package_version_file("${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" - VERSION 1.64 - COMPATIBILITY AnyNewerVersion - ) - - install(FILES - "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" - "${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" - DESTINATION lib/cmake/boost_filesystem - ) - ---------------------------- -Building standalone with CM ---------------------------- - -The boost cmake modules can help reduce the boilerplate needed in writing these libraries. To use these modules we just call ``find_package(CM)`` first:: - - cmake_minimum_required(VERSION 3.5) - project(boost_filesystem) - find_package(CM) - -Next we can setup the version for the project using ``cm_setup_version``:: - - cm_setup_version(VERSION 1.64) - -Next, we add the library and link against the dependencies like always:: - - find_package(boost_core) - find_package(boost_static_assert) - find_package(boost_iterator) - find_package(boost_detail) - find_package(boost_system) - find_package(boost_functional) - find_package(boost_assert) - find_package(boost_range) - find_package(boost_type_traits) - find_package(boost_smart_ptr) - find_package(boost_io) - find_package(boost_config) - - add_library(boost_filesystem - src/operations.cpp - src/portability.cpp - src/codecvt_error_category.cpp - src/utf8_codecvt_facet.cpp - src/windows_file_codecvt.cpp - src/unique_path.cpp - src/path.cpp - src/path_traits.cpp - ) - add_library(boost::filesystem ALIAS boost_filesystem) - set_property(TARGET boost_filesystem PROPERTY EXPORT_NAME filesystem) - - target_link_libraries(boost_filesystem PUBLIC - boost::core - boost::static_assert - boost::iterator - boost::detail - boost::system - boost::functional - boost::assert - boost::range - boost::type_traits - boost::smart_ptr - boost::io - boost::config - ) - -Then to install, and generate package configuration we just use ``cm_deploy``:: - - cm_deploy(TARGETS boost_filesystem NAMESPACE boost::) - -In addition to generating package configuration for cmake, this will also generate the package configuration for ``pkgconfig``. - ------------------ -Integrated builds ------------------ - -As we were setting up cmake for standalone builds, we made sure we didn't do anything to prevent an integrated build, and even provided an alias target to help ease the process. Finally, to integrate the sources into the build is just a matter of calling ``add_subdirectory`` on each project:: - - file(GLOB LIBS libs/*) - foreach(lib ${LIBS}) - add_subdirectory(${lib}) - endforeach() - -We could also use ``add_subdirectory(${lib} EXCLUDE_FROM_ALL)`` so it builds targets that are not necessary. Of course, every project is still calling ``find_package`` to find prebuilt binaries. Since we don't need to search for those libraries because they are integrated into the build we can call ``cm_ignore_package`` to ignore those dependencies:: - - file(GLOB LIBS libs/*) - - foreach(lib ${LIBS}) - cm_ignore_package(${lib}) - endforeach() - - foreach(lib ${LIBS}) - add_subdirectory(${lib}) - endforeach() - -Of course, this assumes we have conveniently named each directory the same as its package name. diff --git a/cmake/modules/doc/src/CMDeploy.rst b/cmake/modules/doc/src/CMDeploy.rst deleted file mode 100644 index 4032bcca53..0000000000 --- a/cmake/modules/doc/src/CMDeploy.rst +++ /dev/null @@ -1,28 +0,0 @@ -========= -CMDeploy -========= - ----------- -cm_deploy ----------- - -.. program:: cm_deploy - -This will install targets, as well as generate package configuration for both cmake and pkgconfig. - -.. option:: TARGETS ... - -The name of the targets to deploy. - -.. option:: INCLUDE ... - -Include directories to be installed. It also makes the include directory available for targets to be installed. - -.. option:: NAMESPACE - -This is the namespace to add to the targets that are exported. - -.. option:: COMPATIBILITY - -This uses the version compatibility specified by cmake version config. - diff --git a/cmake/modules/doc/src/CMExport.rst b/cmake/modules/doc/src/CMExport.rst deleted file mode 100644 index 6bbca02710..0000000000 --- a/cmake/modules/doc/src/CMExport.rst +++ /dev/null @@ -1,31 +0,0 @@ -========= -CMExport -========= - ---------------- -cm_auto_export ---------------- - -.. program:: cm_auto_export - -This generates a simple cmake config file that includes the exported targets. - -.. option:: EXPORT - -This specifies an export file. By default, the export file will be named ``${PROJECT_NAME}-targets``. - -.. option:: NAMESPACE - -This is the namespace to add to the targets that are exported. - -.. option:: COMPATIBILITY - -This uses the version compatibility specified by cmake version config. - -.. option:: NAME - -This is the name to use for the package config file. By default, this uses the project name, but this parameter can override it. - -.. option:: TARGETS ... - -These include the targets to be exported. diff --git a/cmake/modules/doc/src/CMIgnorePackage.rst b/cmake/modules/doc/src/CMIgnorePackage.rst deleted file mode 100644 index 03c32a4854..0000000000 --- a/cmake/modules/doc/src/CMIgnorePackage.rst +++ /dev/null @@ -1,15 +0,0 @@ -========= -CMIgnorePackage -========= - ------------------- -cm_ignore_package ------------------- - -.. program:: cm_ignore_package - -This will ignore a package so that subsequent calls to `find_package` will be treated as found. This is useful in the superproject of integrated builds because it will ingore the ``find_package`` calls to a dependency becaue the targets are already provided by ``add_subdirectory``. - -.. option:: NAME - -The name of the package to ignore. \ No newline at end of file diff --git a/cmake/modules/doc/src/CMInstallTargets.rst b/cmake/modules/doc/src/CMInstallTargets.rst deleted file mode 100644 index 8580b84ba2..0000000000 --- a/cmake/modules/doc/src/CMInstallTargets.rst +++ /dev/null @@ -1,25 +0,0 @@ -================= -CMInstallTargets -================= - -------------------- -cm_install_targets -------------------- - -.. program:: cm_install_targets - -This installs the targets specified. The directories will be installed according to GNUInstallDirs. -It will also install a corresponding cmake package config(which can be found with ``find_package``) to link against the library targets. - -.. option:: TARGETS ... - -The name of the targets to install. - -.. option:: INCLUDE ... - -Include directories to be installed. It also makes the include directory available for targets to be installed. - -.. option:: EXPORT - -This specifies an export file. By default, the export file will be named ``${PROJECT_NAME}-targets``. - diff --git a/cmake/modules/doc/src/CMPkgConfig.rst b/cmake/modules/doc/src/CMPkgConfig.rst deleted file mode 100644 index 470485968b..0000000000 --- a/cmake/modules/doc/src/CMPkgConfig.rst +++ /dev/null @@ -1,59 +0,0 @@ -============ -CMPkgConfig -============ - ---------------------------- -cm_generate_pkgconfig_file ---------------------------- - -.. program:: cm_generate_pkgconfig_file - -This will generate a simple pkgconfig file. - -.. option:: NAME - -This is the name of the pkgconfig module. - -.. option:: LIB_DIR - -This is the directory where the library is linked to. This defaults to ``${CMAKE_INSTALL_LIBDIR}``. - -.. option:: INCLUDE_DIR - -This is the include directory where the header file are installed. This defaults to ``${CMAKE_INSTALL_INCLUDEDIR}``. - -.. option:: DESCRIPTION - -A description about the library. - -.. option:: TARGETS ... - -The library targets to link. - -.. option:: CFLAGS ... - -Additionaly, compiler flags. - -.. option:: LIBS ... - -Additional libraries to be linked. - -.. option:: REQUIRES ... - -List of other pkgconfig packages that this module depends on. - ------------------- -cm_auto_pkgconfig ------------------- - -.. program:: cm_auto_pkgconfig - -This will auto generate pkgconfig from a given target. All the compiler and linker flags come from the target. - -.. option:: NAME - -This is the name of the pkgconfig module. By default, this will use the project name. - -.. option:: TARGET - -This is the target which will be used to set the various pkgconfig fields. diff --git a/cmake/modules/doc/src/CMProperties.rst b/cmake/modules/doc/src/CMProperties.rst deleted file mode 100644 index 37880d0fce..0000000000 --- a/cmake/modules/doc/src/CMProperties.rst +++ /dev/null @@ -1,65 +0,0 @@ -============= -CMProperties -============= - -This module defines several properties that can be used to control language features in C++. - --------------- -CXX_EXCEPTIONS --------------- - -This property can be used to enable or disable C++ exceptions. This can be applied at global, directory or target scope. At global scope this defaults to On. - --------- -CXX_RTTI --------- - -This property can be used to enable or disable C++ runtime type information. This can be applied at global, directory or target scope. At global scope this defaults to On. - ------------------- -CXX_STATIC_RUNTIME ------------------- - -This property can be used to enable or disable linking against the static C++ runtime. This can be applied at global, directory or target scope. At global scope this defaults to Off. - ------------- -CXX_WARNINGS ------------- - -The ``CXX_WARNINGS`` property controls the warning level of compilers. It has the following values: - -* ``off`` - disables all warnings. -* ``on`` - enables default warning level for the tool. -* ``all`` - enables all warnings. - -Default value is ``on``. - ----------------------- -CXX_WARNINGS_AS_ERRORS ----------------------- - -The ``CXX_WARNINGS_AS_ERRORS`` property makes it possible to treat warnings as errors and abort compilation on a warning. The value ``on`` enables this behaviour. The default value is ``off``. - ---------------------- -INTERFACE_DESCRIPTION ---------------------- - -Description of the target. - -------------- -INTERFACE_URL -------------- - -An URL where people can get more information about and download the package. - ------------------------------ -INTERFACE_PKG_CONFIG_REQUIRES ------------------------------ - -A list of packages required by this package for pkgconfig. The versions of these packages may be specified using the comparison operators =, <, >, <= or >=. - -------------------------- -INTERFACE_PKG_CONFIG_NAME -------------------------- - -The name of the pkgconfig package for this target. diff --git a/cmake/modules/doc/src/CMSetupVersion.rst b/cmake/modules/doc/src/CMSetupVersion.rst deleted file mode 100644 index d9f145c777..0000000000 --- a/cmake/modules/doc/src/CMSetupVersion.rst +++ /dev/null @@ -1,33 +0,0 @@ -=============== -CMSetupVersion -=============== - ------------------ -cm_setup_version ------------------ - -.. program:: cm_setup_version - -This sets up the project version by setting these version variables:: - - PROJECT_VERSION, ${PROJECT_NAME}_VERSION - PROJECT_VERSION_MAJOR, ${PROJECT_NAME}_VERSION_MAJOR - PROJECT_VERSION_MINOR, ${PROJECT_NAME}_VERSION_MINOR - PROJECT_VERSION_PATCH, ${PROJECT_NAME}_VERSION_PATCH - -.. option:: VERSION .. - -This is the version to be set. - -.. option:: GENERATE_HEADER - -This is a header which will be generated with defines for the version number. - -.. option:: PREFIX - -By default, the upper case of the project name is used as a prefix for the version macros that are defined in the generated header: ``${PREFIX}_VERSION_MAJOR``, ``${PREFIX}_VERSION_MINOR``, ``${PREFIX}_VERSION_PATCH``, and ``${PREFIX}_VERSION``. The ``PREFIX`` option allows overriding the prefix name used for the macros. - -.. option:: PARSE_HEADER - -Rather than set a version and generate a header, this will parse a header with macros that define the version, and then use those values to set the version for the project. - diff --git a/cmake/modules/doc/src/CMTest.rst b/cmake/modules/doc/src/CMTest.rst deleted file mode 100644 index 2d75925b69..0000000000 --- a/cmake/modules/doc/src/CMTest.rst +++ /dev/null @@ -1,89 +0,0 @@ -====== -CMTest -====== - ----------------- -cm_mark_as_test ----------------- - -.. program:: cm_mark_as_test - -This marks the target as a test, so it will be built with the ``tests`` target. If ``BUILD_TESTS`` is set to off then the target will not be built as part of the all target. - ------------------------ -cm_test_link_libraries ------------------------ - -.. program:: cm_test_link_libraries - -This sets libraries that the tests will link against by default. - --------- -cm_test --------- - -.. program:: cm_test - -This setups a test. By default, a test will be built and executed. - -.. option:: SOURCES ... - -Source files to be compiled for the test. - -.. option:: CONTENT - -This a string that will be used to create a test to be compiled and/or ran. - -.. option:: NAME - -Name of the test. - -.. option:: ARGS - -This sets additional arguments to be passed to the test executable when it will be ran. - -.. option:: COMPILE_ONLY - -This just compiles the test instead of running it. As such, a ``main`` function is not required. - -.. option:: WILL_FAIL - -Specifies that the test will fail. - -.. option:: NO_TEST_LIBS - -This won't link in the libraries specified by ``cm_test_link_libraries`` - ---------------- -cm_test_header ---------------- - -.. program:: cm_test_header - -This creates a test to test the include of a header. - -.. option:: NAME - -Name of the test. - -.. option:: HEADER - -The header to include. - -.. option:: STATIC - -Rather than just test the include, using ``STATIC`` option will test the include across translation units. This helps check for incorrect include guards and duplicate symbols. - -.. option:: NO_TEST_LIBS - -This won't link in the libraries specified by ``cm_test_link_libraries`` - -------------------------- -cm_add_test_subdirectory -------------------------- - -.. program:: cm_add_test_subdirectory - -This calls ``add_subdirectory`` if the ``ENABLE_TESTS`` property is true. The default value for the property is set by ``CMAKE_ENABLE_TESTS`` variable. - - diff --git a/cmake/modules/doc/src/Intro.rst b/cmake/modules/doc/src/Intro.rst deleted file mode 100644 index 4174dc7a32..0000000000 --- a/cmake/modules/doc/src/Intro.rst +++ /dev/null @@ -1,89 +0,0 @@ - -========== -Motivation -========== - -This provides cmake modules that can be re-used by boost and other dependencies. It provides modules to reduce the boilerplate for installing, versioning, setting up package config, and creating tests. - -===== -Usage -===== - -The modules can be installed using standard cmake install:: - - mkdir build - cd build - cmake .. - cmake --build . --target install - -Once installed, the modules can be used by using ``find_package`` and then including the appropriate module:: - - find_package(CM) - include(CMDeploy) - -=========== -Quick Start -=========== - ------------------------- -Building a boost library ------------------------- - -The BCM modules provide some high-level cmake functions to take care of all the cmake boilerplate needed to build, install and configuration setup. To setup a simple boost library we can do:: - - cmake_minimum_required (VERSION 3.5) - project(boost_config) - - find_package(CM) - include(CMDeploy) - include(CMSetupVersion) - - cm_setup_version(VERSION 1.58.0) - - add_library(boost_config INTERFACE) - add_library(boost::config ALIAS boost_config) - set_property(TARGET boost_config PROPERTY EXPORT_NAME config) - - cm_deploy(TARGETS config INCLUDE include) - - -This sets up the Boost.Config cmake with the version ``1.64.0``. More importantly the user can now install the library, like this:: - - mkdir build - cd build - cmake .. - cmake --build . --target install - -And then the user can build with Boost.Config using cmake's ``find_package``:: - - project(foo) - - find_package(boost_config) - add_executable(foo foo.cpp) - target_link_libraries(foo boost::config) - -Or if the user isn't using cmake, then ``pkg-config`` can be used instead:: - - g++ `pkg-config boost_config --cflags --libs` foo.cpp - ------ -Tests ------ - -The BCM modules provide functions for creating tests that integrate into cmake's ctest infrastructure. All tests can be built and ran using ``make check``. The ``cm_test`` function can add a test to be ran:: - - cm_test(NAME config_test_c SOURCES config_test_c.c) - -This will compile the ``SOURCES`` and run them. The test also needs to link in ``boost_config``. This can be done with ``target_link_libraries``:: - - target_link_libraries(config_test_c boost::config) - -Or all tests in the directory can be set using ``cm_test_link_libraries``:: - - cm_test_link_libraries(boost::config) - -And all tests in the directory will use ``boost::config``. - -Also, tests can be specified as compile-only or as expected to fail:: - - cm_test(NAME test_thread_fail1 SOURCES threads/test_thread_fail1.cpp COMPILE_ONLY WILL_FAIL) diff --git a/cmake/modules/doc/src/Modules.rst b/cmake/modules/doc/src/Modules.rst deleted file mode 100644 index 1f73b4ccc1..0000000000 --- a/cmake/modules/doc/src/Modules.rst +++ /dev/null @@ -1,15 +0,0 @@ -Modules -======= - -.. toctree:: - :maxdepth: 3 - - CMDeploy - CMExport - CMIgnorePackage - CMInstallTargets - CMPkgConfig - CMProperties - CMSetupVersion - CMTest - diff --git a/cmake/modules/share/modules/cmake/CMConfig.cmake b/cmake/modules/share/modules/cmake/CMConfig.cmake deleted file mode 100644 index dfa0cfc38c..0000000000 --- a/cmake/modules/share/modules/cmake/CMConfig.cmake +++ /dev/null @@ -1,144 +0,0 @@ -list(APPEND CMAKE_MODULE_PATH .) -include(CMFuture) -enable_testing() - -function(contains_path FILEPATH SUBPATH RESULT) - file(RELATIVE_PATH PATH "${SUBPATH}" "${FILEPATH}") - if(${PATH} MATCHES "\\.\\./") - set(${RESULT} FALSE PARENT_SCOPE) - else() - set(${RESULT} TRUE PARENT_SCOPE) - endif() -endfunction() - -function(add_subdirectories curdir) - file(GLOB children RELATIVE ${curdir} ${curdir}/*) - set(dirlist "") - foreach(child ${children}) - if(IS_DIRECTORY ${curdir}/${child}) - file(GLOB is_subproject ${curdir}/${child}/*CMakeLists.txt) - if(is_subproject) - add_subdirectory(${curdir}/${child}) - endif() - endif() - endforeach() -endfunction() - -function(cm_project INPUT_PROJECT_NAME) - set(options) - set(oneValueArgs DESCRIPTION VERSION WORKSPACE_NAME) - set(multiValueArgs LANGUAGES) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if(PARSE_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to workspace(): \"${PARSE_UNPARSED_ARGUMENTS}\"") - endif() - - if(PARSE_WORKSPACE_NAME) - if(PARSE_VERSION AND PARSE_LANGUAGES AND PARSE_DESCRIPTION) - project(${INPUT_WORKSPACE_NAME}_${INPUT_PROJECT_NAME} - VERSION ${PARSE_VERSION} - DESCRIPTION ${PARSE_DESCRIPTION} - LANGUAGES ${PARSE_LANGUAGES}) - elseif(PARSE_LANGUAGES) - project(${INPUT_WORKSPACE_NAME}_${INPUT_PROJECT_NAME} ${PARSE_LANGUAGES}) - else() - project(${INPUT_WORKSPACE_NAME}_${INPUT_PROJECT_NAME}) - endif() - endif() - - set(CURRENT_PROJECT_NAME ${INPUT_PROJECT_NAME} PARENT_SCOPE) - set(CMAKE_PROJECT_NAME ${CMAKE_PROJECT_NAME} PARENT_SCOPE) - set(PROJECT_NAME ${INPUT_PROJECT_NAME} PARENT_SCOPE) - - string(TOUPPER ${INPUT_PROJECT_NAME} UPPER_PROJECT_NAME) - set(CURRENT_UPPER_PROJECT_NAME ${UPPER_PROJECT_NAME} PARENT_SCOPE) - - if(PARSE_WORKSPACE_NAME) - file(RELATIVE_PATH RELATIVE_DIR ${CMAKE_WORKSPACE_DIR} .) - - set(CURRENT_SOURCES_DIR ${CMAKE_WORKSPACE_SOURCES_DIR}/${RELATIVE_DIR} PARENT_SCOPE) - set(CURRENT_TEST_SOURCES_DIR ${CMAKE_WORKSPACE_SOURCES_DIR}/${RELATIVE_DIR}/test PARENT_SCOPE) - endif() -endfunction() - -function(cm_workspace WORKSPACE_NAME) - set(options) - set(oneValueArgs DESCRIPTION VERSION SOURCES_DIR) - set(multiValueArgs LANGUAGES) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if(PARSE_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to workspace(): \"${PARSE_UNPARSED_ARGUMENTS}\"") - endif() - - project(${WORKSPACE_NAME} ${PARSE_VERSION} ${PARSE_DESCRIPTION} ${PARSE_LANGUAGES}) - if (NOT PROJECT_NAME) - set(PROJECT_NAME ${WORKSPACE_NAME} PARENT_SCOPE) - endif() - if (NOT CMAKE_PROJECT_NAME) - set(CMAKE_PROJECT_NAME ${WORKSPACE_NAME} PARENT_SCOPE) - endif() - set(CMAKE_WORKSPACE_NAME ${WORKSPACE_NAME} PARENT_SCOPE) - set(CMAKE_WORKSPACE_LIST ${CMAKE_WORKSPACE_LIST} ${CMAKE_WORKSPACE_NAME} PARENT_SCOPE) - set(CMAKE_WORKSPACE_DIR . PARENT_SCOPE) - string(TOUPPER ${WORKSPACE_NAME} UPPER_WORKSPACE_NAME) - set(CMAKE_UPPER_WORKSPACE_NAME ${UPPER_WORKSPACE_NAME} PARENT_SCOPE) - - if(PARSE_SOURCES_DIR) - set(CMAKE_WORKSPACE_SOURCES_DIR ${PARSE_SOURCES_DIR} PARENT_SCOPE) - endif() -endfunction() - -function(patch_file INPUT_SOURCE INPUT_PATCH OUTPUT_DIRECTORY) - set(options) - set(oneValueArgs PREFIX_PATCH_NAME POSTFIX_PATCH_NAME) - set(multiValueArgs) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - find_package(Patch) - if(NOT Patch_FOUND) - message("Patch utulity is not found") - endif() - string(REPLACE ${CURRENT_TEST_SOURCES_DIR} ${CMAKE_CURRENT_BINARY_DIR} OUTPUT_FILE ${INPUT_SOURCE}) - file(COPY ${INPUT_SOURCE} DESTINATION ${OUTPUT_DIRECTORY}) - get_filename_component(SOURCE_FILE_NAME ${INPUT_SOURCE} NAME) - set(NEW_SOURCE_FILE_NAME ${PARSE_PREFIX_PATCH_NAME}${SOURCE_FILE_NAME}) - if(PARSE_POSTFIX_PATCH_NAME) - string(REPLACE . ${PARSE_POSTFIX_PATCH_NAME}. NEW_SOURCE_FILE_NAME ${NEW_SOURCE_FILE_NAME}) - endif() - file(RENAME ${OUTPUT_DIRECTORY}/${SOURCE_FILE_NAME} ${OUTPUT_DIRECTORY}/${NEW_SOURCE_FILE_NAME}) - execute_process(COMMAND patch ${OUTPUT_DIRECTORY}/${NEW_SOURCE_FILE_NAME} ${INPUT_PATCH} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -endfunction() - -function(patch_directory SOURCES_DIRECTORY PATCHES_DIRECTORY OUTPUT_DIRECTORY) - set(options) - set(oneValueArgs PREFIX_PATCH_NAME POSTFIX_PATCH_NAME) - set(multiValueArgs) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - find_package(Patch) - if(NOT Patch_FOUND) - message("Patch utulity is not found") - endif() - file(GLOB_RECURSE PATCHES_FILES LIST_DIRECTORIES FALSE ${PATCHES_DIRECTORY}/*.patch) - file(GLOB_RECURSE SOURCES_FILES LIST_DIRECTORIES FALSE ${SOURCES_DIRECTORY}/*) - foreach(PATCH_FILE IN LISTS PATCHES_FILES) - string(REPLACE ".patch" "" SOURCE_FILE_NAME ${PATCH_FILE}) - string(REPLACE ${PATCHES_DIRECTORY} ${SOURCES_DIRECTORY} SOURCE_FILE_NAME ${SOURCE_FILE_NAME}) - list(FIND SOURCES_FILES ${SOURCE_FILE_NAME} SOURCES_FILE_FIND) - if(${SOURCES_FILE_FIND} EQUAL -1) - message(FATAL_ERROR "Source file for patch is not found: " ${PATCH_FILE}) - endif() - list(GET SOURCES_FILES ${SOURCES_FILE_FIND} SOURCE_FILE) - string(REPLACE ${SOURCES_DIRECTORY} ${OUTPUT_DIRECTORY} OUTPUT_FILE_DIRECTORY ${SOURCE_FILE}) - get_filename_component(OUTPUT_FILE_DIRECTORY ${OUTPUT_FILE_DIRECTORY} DIRECTORY) - patch_file(${SOURCE_FILE} ${PATCH_FILE} ${OUTPUT_FILE_DIRECTORY} - PREFIX_PATCH_NAME ${PARSE_PREFIX_PATCH_NAME} POSTFIX_PATCH_NAME ${PARSE_POSTFIX_PATCH_NAME}) - endforeach() -endfunction() diff --git a/cmake/modules/share/modules/cmake/CMDeploy.cmake b/cmake/modules/share/modules/cmake/CMDeploy.cmake deleted file mode 100644 index eb686ab685..0000000000 --- a/cmake/modules/share/modules/cmake/CMDeploy.cmake +++ /dev/null @@ -1,48 +0,0 @@ - -include(CMPkgConfig) -include(CMInstallTargets) -include(CMExport) - -function(cm_deploy) - set(options SKIP_HEADER_INSTALL) - set(oneValueArgs NAMESPACE COMPATIBILITY PACKAGE_NAME) - set(multiValueArgs TARGETS INCLUDE) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if(PARSE_PACKAGE_NAME) - set(PACKAGE_NAME ${PARSE_PACKAGE_NAME}) - else() - set(PACKAGE_NAME ${PROJECT_NAME}) - endif() - - if(PARSE_SKIP_HEADER_INSTALL) - cm_install_targets(TARGETS ${PARSE_TARGETS} INCLUDE ${PARSE_INCLUDE} SKIP_HEADER_INSTALL) - else() - cm_install_targets(TARGETS ${PARSE_TARGETS} INCLUDE ${PARSE_INCLUDE}) - endif() - - cm_auto_pkgconfig(TARGET ${PARSE_TARGETS}) - cm_auto_export(TARGETS ${PARSE_TARGETS} NAMESPACE ${PARSE_NAMESPACE} COMPATIBILITY ${PARSE_COMPATIBILITY}) - - foreach(TARGET ${PARSE_TARGETS}) - get_target_property(TARGET_NAME ${TARGET} EXPORT_NAME) - if(NOT TARGET_NAME) - get_target_property(TARGET_NAME ${TARGET} NAME) - endif() - set(EXPORT_LIB_TARGET ${PARSE_NAMESPACE}${TARGET_NAME}) - if(NOT TARGET ${EXPORT_LIB_TARGET}) - add_library(${EXPORT_LIB_TARGET} ALIAS ${TARGET}) - endif() - set_target_properties(${TARGET} PROPERTIES INTERFACE_FIND_PACKAGE_NAME ${PARSE_NAMESPACE}${PACKAGE_NAME}) - if(COMMAND cm_add_rpath) - get_target_property(TARGET_TYPE ${TARGET} TYPE) - if(NOT "${TARGET_TYPE}" STREQUAL "INTERFACE_LIBRARY") - cm_add_rpath("$") - endif() - endif() - cm_shadow_notify(${EXPORT_LIB_TARGET}) - cm_shadow_notify(${TARGET}) - endforeach() - -endfunction() diff --git a/cmake/modules/share/modules/cmake/CMExport.cmake b/cmake/modules/share/modules/cmake/CMExport.cmake deleted file mode 100644 index 552067f148..0000000000 --- a/cmake/modules/share/modules/cmake/CMExport.cmake +++ /dev/null @@ -1,147 +0,0 @@ -include(GNUInstallDirs) -include(WriteBasicConfigVersionFile) - -function(cm_get_target_package_source OUT_VAR TARGET) - set(RESULT) - if(TARGET ${TARGET}) - get_property(TARGET_ALIAS TARGET ${TARGET} PROPERTY ALIASED_TARGET) - if(TARGET_ALIAS) - set(TARGET ${TARGET_ALIAS}) - endif() - get_property(TARGET_IMPORTED TARGET ${TARGET} PROPERTY IMPORTED) - if(TARGET_IMPORTED OR TARGET_ALIAS) - get_property(TARGET_FIND_PACKAGE_NAME TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_NAME) - if(NOT TARGET_FIND_PACKAGE_NAME) - message(SEND_ERROR "The target ${TARGET_FIND_PACKAGE_NAME} does not have information about find_package() call.") - endif() - set(PKG_NAME ${TARGET_FIND_PACKAGE_NAME}) - get_property(TARGET_FIND_PACKAGE_VERSION TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_VERSION) - if(TARGET_FIND_PACKAGE_VERSION) - set(PKG_NAME "${PKG_NAME} ${TARGET_FIND_PACKAGE_VERSION}") - endif() - get_property(TARGET_FIND_PACKAGE_EXACT TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_EXACT) - if(TARGET_FIND_PACKAGE_EXACT) - set(PKG_NAME "${PKG_NAME} ${TARGET_FIND_PACKAGE_EXACT}") - endif() - set(RESULT "${PKG_NAME}") - # get_property(TARGET_FIND_PACKAGE_REQUIRED TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_REQUIRED) - # get_property(TARGET_FIND_PACKAGE_QUIETLY TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_QUIETLY) - endif() - else() - if("${TARGET}" MATCHES "::") - set(TARGET_NAME "$") - else() - set(TARGET_NAME "${TARGET}") - endif() - cm_shadow_exists(HAS_TARGET ${TARGET}) - set(RESULT "$<${HAS_TARGET}:$>") - endif() - set(${OUT_VAR} "${RESULT}" PARENT_SCOPE) -endfunction() - -function(cm_auto_export) - set(options) - set(oneValueArgs NAMESPACE EXPORT NAME COMPATIBILITY) - set(multiValueArgs TARGETS) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) - string(TOLOWER ${CMAKE_WORKSPACE_NAME} CMAKE_WORKSPACE_NAME_LOWER) - set(PACKAGE_NAME ${PROJECT_NAME}) - if(PARSE_NAME) - set(PACKAGE_NAME ${PARSE_NAME}) - endif() - - string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER) - string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) - - set(TARGET_FILE ${CMAKE_WORKSPACE_NAME_LOWER}-${PROJECT_NAME_LOWER}-targets) - if(PARSE_EXPORT) - set(TARGET_FILE ${PARSE_EXPORT}) - endif() - set(CONFIG_NAME ${PACKAGE_NAME_LOWER}-config) - set(TARGET_VERSION ${PROJECT_VERSION}) - - set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) - set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) - set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) - set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/${PACKAGE_NAME_LOWER}) - - set(CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}.cmake") - - set(CONFIG_FILE_CONTENT " -include(CMakeFindDependencyMacro) -") - - if(PARSE_TARGETS) - # Add dependencies - foreach(TARGET ${PARSE_TARGETS}) - get_property(TARGET_LIBS TARGET ${TARGET} PROPERTY INTERFACE_LINK_LIBRARIES) - foreach(LIB ${TARGET_LIBS}) - cm_get_target_package_source(PKG_SRC ${LIB}) - set(HAS_PKG_SRC "$") - string(APPEND CONFIG_FILE_CONTENT "# $<$:Skip >Library: ${LIB}\n") - string(APPEND CONFIG_FILE_CONTENT "$<${HAS_PKG_SRC}:find_dependency(${PKG_SRC})>\n") - endforeach() - endforeach() - # Compute targets imported name - set(EXPORT_LIB_TARGETS) - foreach(TARGET ${PARSE_TARGETS}) - get_target_property(TARGET_NAME ${TARGET} EXPORT_NAME) - if(NOT TARGET_NAME) - get_target_property(TARGET_NAME ${TARGET} NAME) - endif() - set(EXPORT_LIB_TARGET_${TARGET} ${PARSE_NAMESPACE}${TARGET_NAME}) - list(APPEND EXPORT_LIB_TARGETS ${EXPORT_LIB_TARGET_${TARGET}}) - endforeach() - # Export custom properties - set(EXPORT_PROPERTIES) - foreach(TARGET ${PARSE_TARGETS}) - # TODO: Make this a property: the custom properties to be exported - foreach(PROPERTY INTERFACE_PKG_CONFIG_NAME) - set(PROP "$") - set(EXPORT_PROPERTIES "${EXPORT_PROPERTIES} -$<$:set_target_properties(${EXPORT_LIB_TARGET_${TARGET}} PROPERTIES ${PROPERTY} ${PROP})> -") - endforeach() - endforeach() - string(APPEND CONFIG_FILE_CONTENT " -include(\"\${CMAKE_CURRENT_LIST_DIR}/${TARGET_FILE}.cmake\") -include(\"\${CMAKE_CURRENT_LIST_DIR}/properties-${TARGET_FILE}.cmake\") -") - endif() - - file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/properties-${TARGET_FILE}.cmake CONTENT "${EXPORT_PROPERTIES}") - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/properties-${TARGET_FILE}.cmake DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR}) - - file(GENERATE OUTPUT "${CONFIG_FILE}" CONTENT "${CONFIG_FILE_CONTENT}") - - set(COMPATIBILITY_ARG SameMajorVersion) - if(PARSE_COMPATIBILITY) - set(COMPATIBILITY_ARG ${PARSE_COMPATIBILITY}) - endif() - write_basic_config_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}-version.cmake - VERSION ${TARGET_VERSION} - COMPATIBILITY ${COMPATIBILITY_ARG} - ) - - set(NAMESPACE_ARG) - if(PARSE_NAMESPACE) - set(NAMESPACE_ARG "NAMESPACE;${PARSE_NAMESPACE}") - endif() - install(EXPORT ${TARGET_FILE} - DESTINATION - ${CONFIG_PACKAGE_INSTALL_DIR} - ${NAMESPACE_ARG} - ) - - install(FILES - ${CONFIG_FILE} - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}-version.cmake - DESTINATION - ${CONFIG_PACKAGE_INSTALL_DIR}) - -endfunction() - diff --git a/cmake/modules/share/modules/cmake/CMFuture.cmake b/cmake/modules/share/modules/cmake/CMFuture.cmake deleted file mode 100644 index 68a21c7288..0000000000 --- a/cmake/modules/share/modules/cmake/CMFuture.cmake +++ /dev/null @@ -1,87 +0,0 @@ -define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_NAME" - BRIEF_DOCS "The package name that was searched for to create this target" - FULL_DOCS "The package name that was searched for to create this target" -) - -define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_REQUIRED" - BRIEF_DOCS "true if REQUIRED option was given" - FULL_DOCS "true if REQUIRED option was given" -) - -define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_QUIETLY" - BRIEF_DOCS "true if QUIET option was given" - FULL_DOCS "true if QUIET option was given" -) - -define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_EXACT" - BRIEF_DOCS "true if EXACT option was given" - FULL_DOCS "true if EXACT option was given" -) - -define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_VERSION" - BRIEF_DOCS "full requested version string" - FULL_DOCS "full requested version string" -) - -# Custom property to check if target exists -define_property(TARGET PROPERTY "INTERFACE_TARGET_EXISTS" - BRIEF_DOCS "True if target exists" - FULL_DOCS "True if target exists" -) -# Create shadow target to notify that the target exists -macro(cm_shadow_notify TARGET) - if(NOT TARGET _cm_shadow_target_${TARGET}) - add_library(_cm_shadow_target_${TARGET} INTERFACE IMPORTED GLOBAL) - endif() - set_target_properties(_cm_shadow_target_${TARGET} PROPERTIES INTERFACE_TARGET_EXISTS 1) -endmacro() -# Check if target exists by querying the shadow target -macro(cm_shadow_exists OUT TARGET) - if("${TARGET}" MATCHES "^[_a-zA-Z0-9:]+$") - if(NOT TARGET _cm_shadow_target_${TARGET}) - add_library(_cm_shadow_target_${TARGET} INTERFACE IMPORTED GLOBAL) - set_target_properties(_cm_shadow_target_${TARGET} PROPERTIES INTERFACE_TARGET_EXISTS 0) - endif() - set(${OUT} "$") - else() - set(${OUT} "0") - endif() -endmacro() -# Emulate rpath for windows -if(WIN32) - if(NOT COMMAND cm_add_rpath) - foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES} "") - file(WRITE ${CMAKE_BINARY_DIR}/cm_set_rpath_pre-${CONFIG}.cmake "set(RPATH)\n") - file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/cm_set_rpath-${CONFIG}.cmake INPUT ${CMAKE_BINARY_DIR}/cm_set_rpath_pre-${CONFIG}.cmake CONDITION $) - endforeach() - function(cm_add_rpath) - foreach(_RPATH ${ARGN}) - foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES} "") - file(APPEND ${CMAKE_BINARY_DIR}/cm_set_rpath_pre-${CONFIG}.cmake "list(APPEND RPATH \"${_RPATH}\")\n") - endforeach() - endforeach() - endfunction() - endif() -endif() -# Add library extension to track imported targets -if(NOT COMMAND cm_add_library_ext) - macro(cm_add_library_ext LIB) - set(ARG_LIST "${ARGN}") - if("IMPORTED" IN_LIST ARG_LIST) - if(CMAKE_FIND_PACKAGE_NAME) - set_target_properties(${LIB} PROPERTIES INTERFACE_FIND_PACKAGE_NAME ${CMAKE_FIND_PACKAGE_NAME}) - foreach(TYPE REQUIRED QUIETLY EXACT VERSION) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_${TYPE}) - set_target_properties(${LIB} PROPERTIES INTERFACE_FIND_PACKAGE_${TYPE} ${${CMAKE_FIND_PACKAGE_NAME}_FIND_${TYPE}}) - endif() - endforeach() - endif() - endif() - endmacro() - - macro(add_library) - _add_library(${ARGN}) - cm_add_library_ext(${ARGN}) - endmacro() - -endif() diff --git a/cmake/modules/share/modules/cmake/CMIgnorePackage.cmake b/cmake/modules/share/modules/cmake/CMIgnorePackage.cmake deleted file mode 100644 index 677652d72d..0000000000 --- a/cmake/modules/share/modules/cmake/CMIgnorePackage.cmake +++ /dev/null @@ -1,6 +0,0 @@ - -function(cm_ignore_package NAME) - set(${NAME}_DIR ${CMAKE_BINARY_DIR}/_cm_ignore_packages_/${NAME} CACHE PATH "") - file(WRITE ${${NAME}_DIR}/${NAME}Config.cmake "") -endfunction() - diff --git a/cmake/modules/share/modules/cmake/CMInstallTargets.cmake b/cmake/modules/share/modules/cmake/CMInstallTargets.cmake deleted file mode 100644 index 69dbdd7aaa..0000000000 --- a/cmake/modules/share/modules/cmake/CMInstallTargets.cmake +++ /dev/null @@ -1,43 +0,0 @@ -include(GNUInstallDirs) - -function(cm_install_targets) - set(options SKIP_HEADER_INSTALL) - set(oneValueArgs EXPORT) - set(multiValueArgs TARGETS INCLUDE) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) - string(TOLOWER ${CMAKE_WORKSPACE_NAME} CMAKE_WORKSPACE_NAME_LOWER) - set(EXPORT_FILE ${CMAKE_WORKSPACE_NAME_LOWER}-${PROJECT_NAME_LOWER}-targets) - if(PARSE_EXPORT) - set(EXPORT_FILE ${PARSE_EXPORT}) - endif() - - set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) - set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) - set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) - - foreach(TARGET ${PARSE_TARGETS}) - foreach(INCLUDE ${PARSE_INCLUDE}) - get_filename_component(INCLUDE_PATH ${INCLUDE} ABSOLUTE) - target_include_directories(${TARGET} INTERFACE $) - endforeach() - target_include_directories(${TARGET} INTERFACE $/${INCLUDE_INSTALL_DIR}>) - endforeach() - - - if(NOT PARSE_SKIP_HEADER_INSTALL) - foreach(INCLUDE ${PARSE_INCLUDE}) - install(DIRECTORY ${INCLUDE}/ DESTINATION ${INCLUDE_INSTALL_DIR}) - endforeach() - endif() - - install(TARGETS ${PARSE_TARGETS} - EXPORT ${EXPORT_FILE} - RUNTIME DESTINATION ${BIN_INSTALL_DIR} - LIBRARY DESTINATION ${LIB_INSTALL_DIR} - ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) - -endfunction() - diff --git a/cmake/modules/share/modules/cmake/CMPkgConfig.cmake b/cmake/modules/share/modules/cmake/CMPkgConfig.cmake deleted file mode 100644 index 4e447e8d29..0000000000 --- a/cmake/modules/share/modules/cmake/CMPkgConfig.cmake +++ /dev/null @@ -1,250 +0,0 @@ - -include(GNUInstallDirs) - -define_property(TARGET PROPERTY "INTERFACE_DESCRIPTION" - BRIEF_DOCS "Description of the target" - FULL_DOCS "Description of the target" -) - -define_property(TARGET PROPERTY "INTERFACE_URL" - BRIEF_DOCS "An URL where people can get more information about and download the package." - FULL_DOCS "An URL where people can get more information about and download the package." -) - -define_property(TARGET PROPERTY "INTERFACE_PKG_CONFIG_REQUIRES" - BRIEF_DOCS "A list of packages required by this package. The versions of these packages may be specified using the comparison operators =, <, >, <= or >=." - FULL_DOCS "A list of packages required by this package. The versions of these packages may be specified using the comparison operators =, <, >, <= or >=." -) - -function(cm_generate_pkgconfig_file) - set(options) - set(oneValueArgs NAME LIB_DIR INCLUDE_DIR DESCRIPTION) - set(multiValueArgs TARGETS CFLAGS LIBS REQUIRES) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(LIB_DIR ${CMAKE_INSTALL_LIBDIR}) - if(PARSE_LIB_DIR) - set(LIB_DIR ${PARSE_LIB_DIR}) - endif() - set(INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}) - if(PARSE_INCLUDE_DIR) - set(INCLUDE_DIR ${PARSE_INCLUDE_DIR}) - endif() - - set(LIBS) - set(DESCRIPTION "No description") - if(PARSE_DESCRIPTION) - set(DESCRIPTION ${PARSE_DESCRIPTION}) - endif() - - foreach(TARGET ${PARSE_TARGETS}) - get_property(TARGET_NAME TARGET ${TARGET} PROPERTY NAME) - get_property(TARGET_TYPE TARGET ${TARGET} PROPERTY TYPE) - if(NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY") - set(LIBS "${LIBS} -l${TARGET_NAME}") - endif() - endforeach() - - if(LIBS OR PARSE_LIBS) - set(LIBS "Libs: -L\${libdir} ${LIBS} ${PARSE_LIBS}") - endif() - - set(PKG_NAME ${PROJECT_NAME}) - if(PARSE_NAME) - set(PKG_NAME ${PARSE_NAME}) - endif() - - file(WRITE ${PKGCONFIG_FILENAME} -" -prefix=${CMAKE_INSTALL_PREFIX} -exec_prefix=\${prefix} -libdir=\${exec_prefix}/${LIB_DIR} -includedir=\${exec_prefix}/${INCLUDE_DIR} -Name: ${PKG_NAME} -Description: ${DESCRIPTION} -Version: ${PROJECT_VERSION} -Cflags: -I\${includedir} ${PARSE_CFLAGS} -${LIBS} -Requires: ${PARSE_REQUIRES} -" - ) - -endfunction() - -function(cm_preprocess_pkgconfig_property VAR TARGET PROP) - get_target_property(OUT_PROP ${TARGET} ${PROP}) - string(REPLACE "$/${CMAKE_INSTALL_INCLUDEDIR}" "\${includedir}" OUT_PROP "${OUT_PROP}") - string(REPLACE "$/${CMAKE_INSTALL_LIBDIR}" "\${libdir}" OUT_PROP "${OUT_PROP}") - string(REPLACE "$" "\${prefix}" OUT_PROP "${OUT_PROP}") - - set(${VAR} ${OUT_PROP} PARENT_SCOPE) - -endfunction() - -function(cm_auto_pkgconfig_each) - set(options) - set(oneValueArgs NAME TARGET) - set(multiValueArgs) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(LIBS) - set(CFLAGS) - set(REQUIRES) - set(DESCRIPTION "No description") - - string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) - set(PACKAGE_NAME ${PROJECT_NAME}) - - set(TARGET) - if(PARSE_TARGET) - set(TARGET ${PARSE_TARGET}) - else() - message(SEND_ERROR "Target is required for auto pkg config") - endif() - - if(PARSE_NAME) - set(PACKAGE_NAME ${PARSE_NAME}) - endif() - - string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER) - string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) - - get_property(TARGET_NAME TARGET ${TARGET} PROPERTY NAME) - get_property(TARGET_TYPE TARGET ${TARGET} PROPERTY TYPE) - get_property(TARGET_DESCRIPTION TARGET ${TARGET} PROPERTY INTERFACE_DESCRIPTION) - get_property(TARGET_URL TARGET ${TARGET} PROPERTY INTERFACE_URL) - get_property(TARGET_REQUIRES TARGET ${TARGET} PROPERTY INTERFACE_PKG_CONFIG_REQUIRES) - if(NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY") - set(LIBS "${LIBS} -l${TARGET_NAME}") - endif() - - if(TARGET_REQUIRES) - list(APPEND REQUIRES ${TARGET_REQUIRES}) - endif() - - cm_preprocess_pkgconfig_property(LINK_LIBS ${TARGET} INTERFACE_LINK_LIBRARIES) - foreach(LIB ${LINK_LIBS}) - if(TARGET ${LIB}) - get_property(LIB_PKGCONFIG_NAME TARGET ${LIB} PROPERTY INTERFACE_PKG_CONFIG_NAME) - # TODO: Error if this property is missing - if(LIB_PKGCONFIG_NAME) - list(APPEND REQUIRES ${LIB_PKGCONFIG_NAME}) - endif() - else() - if("${LIB}" MATCHES "::") - set(LIB_TARGET_NAME "$") - else() - set(LIB_TARGET_NAME "${LIB}") - endif() - cm_shadow_exists(HAS_LIB_TARGET ${LIB}) - list(APPEND REQUIRES "$<${HAS_LIB_TARGET}:$>") - set(LIBS "${LIBS} $<$:${LIB}>") - endif() - endforeach() - - cm_preprocess_pkgconfig_property(INCLUDE_DIRS ${TARGET} INTERFACE_INCLUDE_DIRECTORIES) - if(INCLUDE_DIRS) - set(CFLAGS "${CFLAGS} $<$:-I$>") - endif() - - cm_preprocess_pkgconfig_property(COMPILE_DEFS ${TARGET} INTERFACE_COMPILE_DEFINITIONS) - if(COMPILE_DEFS) - set(CFLAGS "${CFLAGS} $<$:-D$>") - endif() - - cm_preprocess_pkgconfig_property(COMPILE_OPTS ${TARGET} INTERFACE_COMPILE_OPTIONS) - if(COMPILE_OPTS) - set(CFLAGS "${CFLAGS} $<$:$>") - endif() - - set(CONTENT) - - if(TARGET_DESCRIPTION) - set(DESCRIPTION "${TARGET_DESCRIPTION}") - endif() - - if(TARGET_URL) - set(CONTENT "${CONTENT}\nUrl: ${TARGET_URL}") - endif() - - if(CFLAGS) - set(CONTENT "${CONTENT}\nCflags: ${CFLAGS}") - endif() - - if(LIBS) - set(CONTENT "${CONTENT}\n$<$:Libs: -L\${libdir} ${LIBS}>") - endif() - - if(REQUIRES) - string(REPLACE ";" "," REQUIRES_CONTENT "${REQUIRES}") - set(CONTENT "${CONTENT}\nRequires: ${REQUIRES_CONTENT}") - endif() - - file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_LOWER}.pc CONTENT -" -prefix=${CMAKE_INSTALL_PREFIX} -exec_prefix=\${prefix} -libdir=\${exec_prefix}/${CMAKE_INSTALL_LIBDIR} -includedir=\${exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR} -Name: ${PACKAGE_NAME_LOWER} -Description: ${DESCRIPTION} -Version: ${PROJECT_VERSION} -${CONTENT} -" - ) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_LOWER}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - set_property(TARGET ${TARGET} PROPERTY INTERFACE_PKG_CONFIG_NAME ${PACKAGE_NAME_LOWER}) -endfunction() - -function(cm_auto_pkgconfig) - set(options) - set(oneValueArgs NAME) - set(multiValueArgs TARGET) # TODO: Rename to TARGETS - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - list(LENGTH PARSE_TARGET TARGET_COUNT) - - if(TARGET_COUNT EQUAL 1) - cm_auto_pkgconfig_each(TARGET ${PARSE_TARGET} NAME ${PARSE_NAME}) - else() - string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) - set(PACKAGE_NAME ${PROJECT_NAME}) - - if(PARSE_NAME) - set(PACKAGE_NAME ${PARSE_NAME}) - endif() - - string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) - - set(GENERATE_PROJECT_PC On) - foreach(TARGET ${PARSE_TARGET}) - if("${TARGET}" STREQUAL "${PACKAGE_NAME_LOWER}") - set(GENERATE_PROJECT_PC Off) - endif() - cm_auto_pkgconfig_each(TARGET ${TARGET} NAME ${TARGET}) - endforeach() - - string(REPLACE ";" "," REQUIRES "${PARSE_TARGET}") - # TODO: Get description from project - set(DESCRIPTION "No description") - - if(GENERATE_PROJECT_PC) - file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_LOWER}.pc CONTENT -" -Name: ${PACKAGE_NAME_LOWER} -Description: ${DESCRIPTION} -Version: ${PROJECT_VERSION} -Requires: ${REQUIRES} -" - ) - endif() - endif() - - -endfunction() diff --git a/cmake/modules/share/modules/cmake/CMProperties.cmake b/cmake/modules/share/modules/cmake/CMProperties.cmake deleted file mode 100644 index c1adea0b99..0000000000 --- a/cmake/modules/share/modules/cmake/CMProperties.cmake +++ /dev/null @@ -1,98 +0,0 @@ -# Custom properties from Niall Douglas - -# On MSVC very annoyingly cmake puts /EHsc and /MD(d) into the global flags which means you -# get a warning when you try to disable exceptions or use the static CRT. I hate to use this -# globally imposed solution, but we are going to hack the global flags to use properties to -# determine whether they are on or off -# -# Create custom properties called CXX_EXCEPTIONS, CXX_RTTI and CXX_STATIC_RUNTIME -# These get placed at global, directory and target scopes -foreach(scope GLOBAL DIRECTORY TARGET) - define_property(${scope} PROPERTY "CXX_EXCEPTIONS" INHERITED - BRIEF_DOCS "Enable C++ exceptions, defaults to TRUE at global scope" - FULL_DOCS "Enable C++ exceptions, defaults to TRUE at global scope" - ) - define_property(${scope} PROPERTY "CXX_RTTI" INHERITED - BRIEF_DOCS "Enable C++ runtime type information, defaults to TRUE at global scope" - FULL_DOCS "Enable C++ runtime type information, defaults to TRUE at global scope" - ) - define_property(${scope} PROPERTY "CXX_STATIC_RUNTIME" INHERITED - BRIEF_DOCS "Enable linking against the static C++ runtime, defaults to FALSE at global scope" - FULL_DOCS "Enable linking against the static C++ runtime, defaults to FALSE at global scope" - ) - define_property(${scope} PROPERTY "CXX_WARNINGS" INHERITED - BRIEF_DOCS "Controls the warning level of compilers, defaults to TRUE at global scope" - FULL_DOCS "Controls the warning level of compilers, defaults to TRUE at global scope" - ) - define_property(${scope} PROPERTY "CXX_WARNINGS_AS_ERRORS" INHERITED - BRIEF_DOCS "Treat warnings as errors and abort compilation on a warning, defaults to FALSE at global scope" - FULL_DOCS "Treat warnings as errors and abort compilation on a warning, defaults to FALSE at global scope" - ) - define_property(${scope} PROPERTY "BUILD_SHARED_LIBS" INHERITED - BRIEF_DOCS "Property indicates wether dynamic-linked libraries are going to be built, defaults to - FALSE at global scope" - FULL_DOCS "Property indicates wether dynamic-linked libraries are going to be built, defaults to - FALSE at global scope" - ) -endforeach() -# Set the default for these properties at global scope. If they are not set per target or -# whatever, the next highest scope will be looked up -option(CMAKE_CXX_EXCEPTIONS "Enable C++ exceptions, defaults to TRUE at global scope" TRUE) -option(CMAKE_CXX_RTTI "Enable C++ runtime type information, defaults to TRUE at global scope" TRUE) -option(CMAKE_CXX_STATIC_RUNTIME "Enable linking against the static C++ runtime, defaults to FALSE at global scope" FALSE) -option(CMAKE_CXX_WARNINGS "Controls the warning level of compilers, defaults to TRUE at global scope" TRUE) -option(CMAKE_CXX_WARNINGS_AS_ERRORS "Treat warnings as errors and abort compilation on a warning, defaults to FALSE at global scope" FALSE) - -set_property(GLOBAL PROPERTY CXX_EXCEPTIONS ${CMAKE_CXX_EXCEPTIONS}) -set_property(GLOBAL PROPERTY CXX_RTTI ${CMAKE_CXX_RTTI}) -set_property(GLOBAL PROPERTY CXX_STATIC_RUNTIME ${CMAKE_CXX_STATIC_RUNTIME}) -set_property(GLOBAL PROPERTY CXX_WARNINGS ${CMAKE_CXX_WARNINGS}) -set_property(GLOBAL PROPERTY CXX_WARNINGS_AS_ERRORS ${CMAKE_CXX_WARNINGS_AS_ERRORS}) -set_property(GLOBAL PROPERTY BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) - -if(MSVC) - # Purge unconditional use of /MDd, /MD and /EHsc. - foreach(flag - CMAKE_C_FLAGS CMAKE_CXX_FLAGS - CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG - CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO - ) - string(REPLACE "/MDd" "" ${flag} "${${flag}}") - string(REPLACE "/MD" "" ${flag} "${${flag}}") - string(REPLACE "/EHsc" "" ${flag} "${${flag}}") - string(REPLACE "/GR" "" ${flag} "${${flag}}") - endforeach() - # Restore those same, but now selected by the properties - add_compile_options( - $<$>,TRUE>:/EHsc> - $<$>,FALSE>:/GR-> - $<$>,FALSE>:$<$:/MDd>$<$>:/MD>> - $<$>,TRUE>:$<$:/MTd>$<$>:/MT>> - $<$>,TRUE>:/W3> - $<$>,FALSE>:/W0> - $<$>,ALL>:/W4> - $<$>,TRUE>:/WX> - ) -else() - add_compile_options( - $<$>,FALSE>:-fno-exceptions> - $<$>,FALSE>:-fno-rtti> - $<$>,TRUE>:-static> - $<$>,TRUE>:-Wall> - $<$>,FALSE>:-w> - $<$>,ALL>:-Wall> - $<$>,ALL>:-pedantic> - $<$>,TRUE>:-Werror> - ) - if(CMAKE_${COMPILER}_COMPILER_ID MATCHES "Clang" OR CMAKE_${COMPILER}_COMPILER_ID MATCHES "AppleClang") - add_compile_options( - $<$>,ALL>:-Weverything> - $<$>,ALL>:-Wno-macro-redefined> - $<$>,ALL>:-Wall> - $<$>,ALL>:-Wno-c++98-compat> - $<$>,ALL>:-Wno-c++98-compat-pedantic> - ) - endif() -endif() \ No newline at end of file diff --git a/cmake/modules/share/modules/cmake/CMSetupVersion.cmake b/cmake/modules/share/modules/cmake/CMSetupVersion.cmake deleted file mode 100644 index b4fe4fb7b6..0000000000 --- a/cmake/modules/share/modules/cmake/CMSetupVersion.cmake +++ /dev/null @@ -1,52 +0,0 @@ -include(GNUInstallDirs) -set(CM_HEADER_VERSION_TEMPLATE_FILE "version.hpp") - -macro(cm_set_parent VAR) - set(${VAR} ${ARGN} PARENT_SCOPE) - set(${VAR} ${ARGN}) -endmacro() - -function(cm_setup_version) - set(options) - set(oneValueArgs VERSION GENERATE_HEADER PARSE_HEADER PREFIX) - set(multiValueArgs) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - string(TOUPPER ${PROJECT_NAME} PREFIX) - - if(PARSE_PREFIX) - set(PREFIX ${PARSE_PREFIX}) - endif() - - if(PARSE_VERSION) - cm_set_parent(PROJECT_VERSION ${PARSE_VERSION}) - cm_set_parent(${PROJECT_NAME}_VERSION ${PROJECT_VERSION}) - string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _version_MAJOR "${PROJECT_VERSION}") - string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _version_MINOR "${PROJECT_VERSION}") - string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _version_PATCH "${PROJECT_VERSION}") - foreach(level MAJOR MINOR PATCH) - cm_set_parent(${PROJECT_NAME}_VERSION_${level} ${_version_${level}}) - cm_set_parent(PROJECT_VERSION_${level} ${_version_${level}}) - endforeach() - elseif(PARSE_PARSE_HEADER) - foreach(level MAJOR MINOR PATCH) - file(STRINGS ${PARSE_PARSE_HEADER} - _define_${level} - REGEX "#define ${PREFIX}_VERSION_${level}") - string(REGEX MATCH "([0-9]+)" _version_${level} "${_define_${level}}") - # TODO: Check if it is empty - cm_set_parent(${PROJECT_NAME}_VERSION_${level} ${_version_${level}}) - cm_set_parent(PROJECT_VERSION_${level} ${_version_${level}}) - endforeach() - cm_set_parent(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") - cm_set_parent(${PROJECT_NAME}_VERSION ${PROJECT_VERSION}) - endif() - # TODO: Get version from the project - - if(PARSE_GENERATE_HEADER) - configure_file("${CM_HEADER_VERSION_TEMPLATE_FILE}" "${PARSE_GENERATE_HEADER}") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PARSE_GENERATE_HEADER}" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - endif() - -endfunction() diff --git a/cmake/modules/share/modules/cmake/CMTest.cmake b/cmake/modules/share/modules/cmake/CMTest.cmake deleted file mode 100644 index 5f8a0e2d04..0000000000 --- a/cmake/modules/share/modules/cmake/CMTest.cmake +++ /dev/null @@ -1,232 +0,0 @@ -option(BUILD_TESTS "Controls whether to build the tests as part of the main build" FALSE) - -enable_testing() - -foreach (scope GLOBAL DIRECTORY) - define_property(${scope} PROPERTY "ENABLE_TESTS" INHERITED - BRIEF_DOCS "Enable tests" - FULL_DOCS "Enable tests" - ) -endforeach () -option(CMAKE_ENABLE_TESTS "Enable tests" ON) -set_property(GLOBAL PROPERTY ENABLE_TESTS ${CMAKE_ENABLE_TESTS}) - -include(ProcessorCount) -processorcount(_cm_ctest_parallel_level) -set(CTEST_PARALLEL_LEVEL ${_cm_ctest_parallel_level} CACHE STRING "CTest parallel level") - -if (NOT TARGET check) - add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR} -j ${CTEST_PARALLEL_LEVEL} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -endif () - - -if (NOT TARGET tests) - add_custom_target(tests COMMENT "Build all tests.") - add_dependencies(check tests) -endif () - -if (NOT TARGET check-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) - add_custom_target(check-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} COMMAND ${CMAKE_CTEST_COMMAND} -L ${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} --output-on-failure -C ${CMAKE_CFG_INTDIR} -j ${CTEST_PARALLEL_LEVEL} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -endif () - -if (NOT TARGET tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) - add_custom_target(tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} COMMENT "Build all tests for ${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}.") - add_dependencies(check-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) -endif () - -function(cm_mark_as_test) - foreach (TEST_TARGET ${ARGN}) - if (NOT BUILD_TESTS) - get_target_property(TEST_TARGET_TYPE ${TEST_TARGET} TYPE) - # We can only use EXCLUDE_FROM_ALL on build targets - if (NOT "${TEST_TARGET_TYPE}" STREQUAL "INTERFACE_LIBRARY") - set_target_properties(${TEST_TARGET} - PROPERTIES EXCLUDE_FROM_ALL TRUE - ) - endif () - endif () - add_dependencies(tests ${TEST_TARGET}) - add_dependencies(tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} ${TEST_TARGET}) - endforeach () -endfunction(cm_mark_as_test) - - -function(cm_create_internal_targets) - if (NOT TARGET _cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}.cpp "") - add_library(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} STATIC ${CMAKE_CURRENT_BINARY_DIR}/_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}.cpp) - cm_mark_as_test(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) - endif () -endfunction() - -foreach (scope DIRECTORY TARGET) - define_property(${scope} PROPERTY "CM_TEST_DEPENDENCIES" INHERITED - BRIEF_DOCS "Default test dependencies" - FULL_DOCS "Default test dependencies" - ) -endforeach () - -function(cm_test_link_libraries) - cm_create_internal_targets() - if (BUILD_TESTS) - set_property(DIRECTORY APPEND PROPERTY CM_TEST_DEPENDENCIES ${ARGN}) - target_link_libraries(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} ${ARGN}) - else () - foreach (TARGET ${ARGN}) - if (TARGET ${TARGET}) - set_property(DIRECTORY APPEND PROPERTY CM_TEST_DEPENDENCIES ${TARGET}) - target_link_libraries(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} ${TARGET}) - elseif (${TARGET} MATCHES "::") - cm_shadow_exists(HAS_TARGET ${TARGET}) - set_property(DIRECTORY APPEND PROPERTY CM_TEST_DEPENDENCIES $<${HAS_TARGET}:${TARGET}>) - target_link_libraries(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} $<${HAS_TARGET}:${TARGET}>) - else () - set_property(DIRECTORY APPEND PROPERTY CM_TEST_DEPENDENCIES ${TARGET}) - target_link_libraries(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} ${TARGET}) - endif () - if (BUILD_SHARED_LIBS) - target_compile_definitions(_cm_internal_tests-${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME} PRIVATE -DBOOST_TEST_DYN_LINK=1 -DBOOST_TEST_NO_AUTO_LINK=1) - endif () - endforeach () - endif () -endfunction() - -function(cm_target_link_test_libs TARGET) - # target_link_libraries(${TARGET} - # $ - # ) - get_property(DEPS DIRECTORY PROPERTY CM_TEST_DEPENDENCIES) - target_link_libraries(${TARGET} ${DEPS}) -endfunction() - - -function(cm_test) - set(options COMPILE_ONLY WILL_FAIL NO_TEST_LIBS) - set(oneValueArgs NAME SOURCES_PREFIX) - set(multiValueArgs SOURCES CONTENT ARGS) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (PARSE_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to cm_test(): \"${PARSE_UNPARSED_ARGUMENTS}\"") - endif () - - set(SOURCES ${PARSE_SOURCES}) - - if (PARSE_NAME) - set(TEST_NAME ${PARSE_NAME}) - else () - string(MAKE_C_IDENTIFIER "${CMAKE_WORKSPACE_NAME}_${PROJECT_NAME}_${SOURCES}_test" TEST_NAME) - endif () - - if (PARSE_CONTENT) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generated-${TEST_NAME}.cpp "${PARSE_CONTENT}") - set(SOURCES ${CMAKE_CURRENT_BINARY_DIR}/generated-${TEST_NAME}.cpp) - endif () - - if (PARSE_COMPILE_ONLY) - add_library(${TEST_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES}) - add_test(NAME ${TEST_NAME} - COMMAND ${CMAKE_COMMAND} --build . --target ${TEST_NAME} --config $ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) - if (PARSE_SOURCES_PREFIX) - target_include_directories(${TEST_NAME} PRIVATE ${PARSE_SOURCES_PREFIX}) - else () - target_include_directories(${TEST_NAME} PRIVATE .) - endif () - - # set_tests_properties(${TEST_NAME} PROPERTIES RESOURCE_LOCK cm_test_compile_only) - else () - add_executable(${TEST_NAME} ${SOURCES}) - cm_mark_as_test(${TEST_NAME}) - if (PARSE_SOURCES_PREFIX) - target_include_directories(${TEST_NAME} PRIVATE ${PARSE_SOURCES_PREFIX}) - else () - target_include_directories(${TEST_NAME} PRIVATE .) - endif () - if (WIN32) - foreach (CONFIG ${CMAKE_CONFIGURATION_TYPES} "") - file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}-test-run-${CONFIG}.cmake CONTENT " -include(\"${CMAKE_BINARY_DIR}/cm_set_rpath-$.cmake\") -if(CMAKE_CROSSCOMPILING) -foreach(RP \${RPATH}) - execute_process(COMMAND winepath -w \${RP} OUTPUT_VARIABLE _RPATH) - string(STRIP \"\${_RPATH}\" _RPATH) - set(ENV{WINEPATH} \"\${_RPATH};\$ENV{WINEPATH}\") -endforeach() -else() -set(ENV{PATH} \"\${RPATH};\$ENV{PATH}\") -endif() -execute_process( - COMMAND $ ${PARSE_ARGS} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE RESULT) -if(NOT RESULT EQUAL 0) - message(FATAL_ERROR \"Test failed\") -endif() -" CONDITION $) - endforeach () - add_test(NAME ${TEST_NAME} COMMAND ${CMAKE_COMMAND} -DCMAKE_CROSSCOMPILING=${CMAKE_CROSSCOMPILING} -P ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}-test-run-$.cmake) - else () - add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME} ${PARSE_ARGS} WORKING_DIRECTORY .) - endif () - endif () - - if (BUILD_SHARED_LIBS) - target_compile_definitions(${TEST_NAME} PRIVATE -DBOOST_TEST_DYN_LINK=1 -DBOOST_TEST_NO_AUTO_LINK=1) - endif () - - if (PARSE_WILL_FAIL) - set_tests_properties(${TEST_NAME} PROPERTIES WILL_FAIL TRUE) - endif () - set_tests_properties(${TEST_NAME} PROPERTIES LABELS ${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) - if (NOT PARSE_NO_TEST_LIBS) - cm_target_link_test_libs(${TEST_NAME}) - endif () -endfunction(cm_test) - -function(cm_test_header) - set(options STATIC NO_TEST_LIBS) - set(oneValueArgs NAME HEADER) - set(multiValueArgs) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (PARSE_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to cm_test_header(): \"${PARSE_UNPARSED_ARGUMENTS}\"") - endif () - - if (PARSE_NAME) - set(TEST_NAME ${PARSE_NAME}) - else () - string(MAKE_C_IDENTIFIER "${CMAKE_WORKSPACE_NAME}_${PROJECT_NAME}_${PARSE_HEADER}_header_test" TEST_NAME) - endif () - - if (PARSE_STATIC) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/header-main-include-${TEST_NAME}.cpp - "#include <${PARSE_HEADER}>\nint main() {}\n" - ) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/header-static-include-${TEST_NAME}.cpp - "#include <${PARSE_HEADER}>\n" - ) - cm_test(NAME ${TEST_NAME} SOURCES - ${CMAKE_CURRENT_BINARY_DIR}/header-main-include-${TEST_NAME}.cpp - ${CMAKE_CURRENT_BINARY_DIR}/header-static-include-${TEST_NAME}.cpp - ) - else () - cm_test(NAME ${TEST_NAME} CONTENT - "#include <${PARSE_HEADER}>\nint main() {}\n" - ) - endif () - set_tests_properties(${TEST_NAME} PROPERTIES LABELS ${CMAKE_WORKSPACE_NAME}-${PROJECT_NAME}) -endfunction(cm_test_header) - -macro(cm_add_test_subdirectory) - get_directory_property(_enable_tests_property ENABLE_TESTS) - get_property(_enable_tests_global_property GLOBAL PROPERTY ENABLE_TESTS) - string(TOUPPER "${_enable_tests_property}" _enable_tests_property_upper) - if (_enable_tests_property_upper STREQUAL "OFF" OR _enable_tests_property_upper EQUAL 1) - set(CURRENT_SOURCES_DIR ${CURRENT_SOURCES_DIR}/test) - add_subdirectory(${ARGN}) - endif () -endmacro() diff --git a/cmake/modules/share/modules/cmake/CMToSnakeCase.cmake b/cmake/modules/share/modules/cmake/CMToSnakeCase.cmake deleted file mode 100644 index ebb49a0bfd..0000000000 --- a/cmake/modules/share/modules/cmake/CMToSnakeCase.cmake +++ /dev/null @@ -1,11 +0,0 @@ - -function(to_snake_case str var) - # insert an underscore before any upper case letter - # which is not followed by another upper case letter - string(REGEX REPLACE "(.)([A-Z][a-z]+)" "\\1_\\2" value "${str}") - # insert an underscore before any upper case letter - # which is preseded by a lower case letter or number - string(REGEX REPLACE "([a-z0-9])([A-Z])" "\\1_\\2" value "${value}") - string(TOLOWER "${value}" value) - set(${var} "${value}" PARENT_SCOPE) -endfunction() diff --git a/cmake/modules/share/modules/cmake/version.hpp b/cmake/modules/share/modules/cmake/version.hpp deleted file mode 100644 index 3162ea4af6..0000000000 --- a/cmake/modules/share/modules/cmake/version.hpp +++ /dev/null @@ -1,10 +0,0 @@ - -#ifndef @PREFIX@_GUARD_VERSION_HPP -#define @PREFIX@_GUARD_VERSION_HPP - -#define @PREFIX@_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ -#define @PREFIX@_VERSION_MINOR @PROJECT_VERSION_MINOR@ -#define @PREFIX@_VERSION_PATCH @PROJECT_VERSION_PATCH@ -#define @PREFIX@_VERSION (((@PREFIX@_VERSION_MAJOR) << 24) + ((@PREFIX@_VERSION_MINOR) << 16) + (@PREFIX@_VERSION_PATCH)) - -#endif diff --git a/cmake/modules/test/CMakeLists.txt b/cmake/modules/test/CMakeLists.txt deleted file mode 100644 index 4e7eb32658..0000000000 --- a/cmake/modules/test/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ - -cmake_policy(SET CMP0057 NEW) - -set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/tmp) - -set(SKIP_TESTS) - -if(DEFINED ENV{APPVEYOR}) - list(APPEND SKIP_TESTS - pass-basic - pass-simplecustomname - pass-simplenamespace - pass-simple-test - ) -endif() - -function(create_test NAME TEST) - set(CONTEXT) - # get_cmake_property(VARS VARIABLES) - foreach(VAR_NAME CMAKE_TOOLCHAIN_FILE CMAKE_CROSSCOMPILING) - list(APPEND CONTEXT -D${VAR_NAME}=${${VAR_NAME}}) - endforeach() - add_custom_target(${NAME} COMMAND ${CMAKE_COMMAND} ${CONTEXT} -P test.cmake ${TEST} ${CMAKE_CURRENT_BINARY_DIR}/tmp/${NAME}) - if(NAME IN_LIST SKIP_TESTS) - add_test(NAME ${NAME} COMMAND echo skipped) - set_tests_properties(${NAME} properties DISABLED On) - else() - add_test(NAME ${NAME} COMMAND ${CMAKE_COMMAND} ${CONTEXT} -P test.cmake ${TEST} ${CMAKE_CURRENT_BINARY_DIR}/tmp/${NAME}) - endif() -endfunction() - -file(GLOB PASS_TESTS pass/*.cmake) -foreach(TEST ${PASS_TESTS}) - get_filename_component(NAME ${TEST} NAME_WE) - create_test(pass-${NAME} ${TEST}) -endforeach() - -file(GLOB FAIL_TESTS fail/*.cmake) -foreach(TEST ${FAIL_TESTS}) - get_filename_component(NAME ${TEST} NAME_WE) - create_test(fail-${NAME} ${TEST}) - set_tests_properties(fail-${NAME} properties WILL_FAIL On) -endforeach() diff --git a/cmake/modules/test/basicapp/CMakeLists.txt b/cmake/modules/test/basicapp/CMakeLists.txt deleted file mode 100644 index a01732a487..0000000000 --- a/cmake/modules/test/basicapp/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(basicapp) - -find_package(CM) - -include(CMInstallTargets) -include(CMDeploy) -include(CMTest) -include(CMSetupVersion) - -cm_setup_version(VERSION 1.0) - -find_package(simple) -add_executable(basicapp main.cpp) -target_link_libraries(basicapp simple) - -cm_install_targets(TARGETS basicapp) - -cm_test(NAME basciapptest SOURCES main.cpp) -target_link_libraries(basciapptest simple) - diff --git a/cmake/modules/test/basicapp/main.cpp b/cmake/modules/test/basicapp/main.cpp deleted file mode 100644 index e13f624519..0000000000 --- a/cmake/modules/test/basicapp/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -int main() { - simple(); -} diff --git a/cmake/modules/test/checkprop/CMakeLists.txt b/cmake/modules/test/checkprop/CMakeLists.txt deleted file mode 100644 index 3eb74b41d5..0000000000 --- a/cmake/modules/test/checkprop/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(checkprop) - -find_package(CM) - -include(CMProperties) - -get_property(CURRENT_PROP_VAL GLOBAL PROPERTY ${PROP_NAME}) - -if(NOT "${CURRENT_PROP_VAL}" STREQUAL "${PROP_VALUE}") - message(FATAL_ERROR "Property ${PROP_NAME} set to ${CURRENT_PROP_VAL}, expected ${PROP_VALUE}") -endif() diff --git a/cmake/modules/test/fail/simple-test.cmake b/cmake/modules/test/fail/simple-test.cmake deleted file mode 100644 index 87a780664f..0000000000 --- a/cmake/modules/test/fail/simple-test.cmake +++ /dev/null @@ -1 +0,0 @@ -install_dir(${TEST_DIR}/simpletest TARGETS check CMAKE_ARGS -DCMAKE_ENABLE_TESTS=Off) diff --git a/cmake/modules/test/findpackagecheck/CMakeLists.txt b/cmake/modules/test/findpackagecheck/CMakeLists.txt deleted file mode 100644 index 4d64882eb2..0000000000 --- a/cmake/modules/test/findpackagecheck/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ - -cmake_minimum_required(VERSION 3.5) -project(findpackagecheck) - -message(STATUS "PKG: ${PKG}") -message(STATUS "PKG_TARGET: ${PKG_TARGET}") - -find_package(${PKG}) - -configure_file(main.cpp.in main.cpp @ONLY) - -add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.cpp) -target_link_libraries(main ${PKG_TARGET}) -install(TARGETS main DESTINATION bin) - diff --git a/cmake/modules/test/findpackagecheck/main.cpp.in b/cmake/modules/test/findpackagecheck/main.cpp.in deleted file mode 100644 index 4c79ac8545..0000000000 --- a/cmake/modules/test/findpackagecheck/main.cpp.in +++ /dev/null @@ -1,4 +0,0 @@ -#include <@PKG_HEADER@> - -int main() { -} diff --git a/cmake/modules/test/libbasic/CMakeLists.txt b/cmake/modules/test/libbasic/CMakeLists.txt deleted file mode 100644 index edf8b3ed81..0000000000 --- a/cmake/modules/test/libbasic/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(basic) - -find_package(CM) - -include(CMInstallTargets) -include(CMDeploy) -include(CMTest) -include(CMSetupVersion) - -cm_setup_version(VERSION 1.0) - -find_package(simple REQUIRED) -add_library(basic main.cpp) -target_link_libraries(basic simple) - -cm_deploy(TARGETS basic) - -cm_test(NAME basictest SOURCES test.cpp) -target_link_libraries(basictest basic) - diff --git a/cmake/modules/test/libbasic/main.cpp b/cmake/modules/test/libbasic/main.cpp deleted file mode 100644 index b31f723fab..0000000000 --- a/cmake/modules/test/libbasic/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -inline void basic() { - simple(); -} diff --git a/cmake/modules/test/libbasic/test.cpp b/cmake/modules/test/libbasic/test.cpp deleted file mode 100644 index b2f997621b..0000000000 --- a/cmake/modules/test/libbasic/test.cpp +++ /dev/null @@ -1,2 +0,0 @@ -int main() { -} diff --git a/cmake/modules/test/libbasicnamespace/CMakeLists.txt b/cmake/modules/test/libbasicnamespace/CMakeLists.txt deleted file mode 100644 index ef821740f3..0000000000 --- a/cmake/modules/test/libbasicnamespace/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(basic) - -find_package(CM) - -include(CMInstallTargets) -include(CMDeploy) -include(CMTest) -include(CMSetupVersion) - -cm_setup_version(VERSION 1.0) - -find_package(simple) -add_library(basic main.cpp) -target_link_libraries(basic lib::simple) - -cm_deploy(TARGETS basic NAMESPACE lib::) - -cm_test(NAME basictest SOURCES test.cpp) -target_link_libraries(basictest basic) - diff --git a/cmake/modules/test/libbasicnamespace/main.cpp b/cmake/modules/test/libbasicnamespace/main.cpp deleted file mode 100644 index 4f4ca4ee45..0000000000 --- a/cmake/modules/test/libbasicnamespace/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -inline void basic() { - simple(); -} diff --git a/cmake/modules/test/libbasicnamespace/test.cpp b/cmake/modules/test/libbasicnamespace/test.cpp deleted file mode 100644 index b2f997621b..0000000000 --- a/cmake/modules/test/libbasicnamespace/test.cpp +++ /dev/null @@ -1,2 +0,0 @@ -int main() { -} diff --git a/cmake/modules/test/libsimple/CMakeLists.txt b/cmake/modules/test/libsimple/CMakeLists.txt deleted file mode 100644 index ae73d456bc..0000000000 --- a/cmake/modules/test/libsimple/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(simple) - -find_package(CM) - -include(CMInstallTargets) -include(CMDeploy) -include(CMSetupVersion) -include(CMTest) -include(CMPkgConfig) - -cm_setup_version(VERSION 1.0 GENERATE_HEADER simpleversion.hpp) - -find_package(Threads) - -add_library(simple INTERFACE) -target_include_directories(simple INTERFACE $/include2>) -target_compile_definitions(simple INTERFACE -DSOME_DEFINE=1 -DHAS_SIMPLE=1 -DDEFINE_3=3) -target_link_libraries(simple INTERFACE Threads::Threads) -if(NOT MSVC) - target_compile_options(simple INTERFACE -std=c++0x) -endif() -cm_test_link_libraries(simple) -install(FILES test.cpp DESTINATION include2) -cm_deploy(TARGETS simple include include) - -cm_test(NAME simpletest SOURCES test.cpp) - -cm_test(SOURCES test.cpp) - -cm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) - -cm_test(SOURCES compiletest.cpp COMPILE_ONLY) - -cm_test(NAME testwillfail SOURCES testwillfail.cpp WILL_FAIL) - -cm_test(SOURCES testwillfail.cpp WILL_FAIL) - -cm_test(NAME simpletestcompilewillfail SOURCES compiletestwillfail.cpp COMPILE_ONLY WILL_FAIL) - -cm_test(SOURCES compiletestwillfail.cpp COMPILE_ONLY WILL_FAIL) - -cm_test_header(NAME simpletestheader HEADER simple.h) - -cm_test_header(HEADER simple.h) - -cm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) - -add_library(simpletestinterface INTERFACE) -cm_mark_as_test(simpletestinterface) - diff --git a/cmake/modules/test/libsimple/compiletest.cpp b/cmake/modules/test/libsimple/compiletest.cpp deleted file mode 100644 index 081fde1f49..0000000000 --- a/cmake/modules/test/libsimple/compiletest.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -int main() { - std::abort(); - simple(); -} \ No newline at end of file diff --git a/cmake/modules/test/libsimple/compiletestwillfail.cpp b/cmake/modules/test/libsimple/compiletestwillfail.cpp deleted file mode 100644 index edde8b46ca..0000000000 --- a/cmake/modules/test/libsimple/compiletestwillfail.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -int main() { - static_assert(false, "Error"); -} \ No newline at end of file diff --git a/cmake/modules/test/libsimple/include/simple.h b/cmake/modules/test/libsimple/include/simple.h deleted file mode 100644 index 36ccbff7a4..0000000000 --- a/cmake/modules/test/libsimple/include/simple.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef GUARD_SIMPLE_H -#define GUARD_SIMPLE_H - -#ifndef __MINGW32__ - -#include - -#endif - -#if !defined(HAS_SIMPLE) || DEFINE_3 != 3 -#error "Not configured" -#endif - -inline void simple() { -#ifndef __MINGW32__ - std::thread([] { - }).join(); -#endif -} - - -#endif diff --git a/cmake/modules/test/libsimple/test.cpp b/cmake/modules/test/libsimple/test.cpp deleted file mode 100644 index c2a02710dc..0000000000 --- a/cmake/modules/test/libsimple/test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - simple(); -} diff --git a/cmake/modules/test/libsimple/testwillfail.cpp b/cmake/modules/test/libsimple/testwillfail.cpp deleted file mode 100644 index 789dcc908a..0000000000 --- a/cmake/modules/test/libsimple/testwillfail.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -int main() { - return 1; -} diff --git a/cmake/modules/test/libsimplecustomname/CMakeLists.txt b/cmake/modules/test/libsimplecustomname/CMakeLists.txt deleted file mode 100644 index 4f05a39168..0000000000 --- a/cmake/modules/test/libsimplecustomname/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(libsimple) - -find_package(CM) - -include(CMInstallTargets) -include(CMDeploy) -include(CMSetupVersion) -include(CMTest) - -cm_setup_version(VERSION 1.0 GENERATE_HEADER simpleversion.hpp) - -add_library(simple INTERFACE) - -cm_install_targets(TARGETS simple include include) -cm_auto_export(TARGETS simple NAME simple) - -cm_test(NAME simpletest SOURCES test.cpp) -target_link_libraries(simpletest simple) - -cm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) -target_link_libraries(simpletestcompile simple) - -cm_test_header(NAME simpletestheader HEADER simple.h) -target_link_libraries(simpletestheader simple) - -cm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) -target_link_libraries(simpleteststaticheader simple) - diff --git a/cmake/modules/test/libsimplecustomname/compiletest.cpp b/cmake/modules/test/libsimplecustomname/compiletest.cpp deleted file mode 100644 index 081fde1f49..0000000000 --- a/cmake/modules/test/libsimplecustomname/compiletest.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -int main() { - std::abort(); - simple(); -} \ No newline at end of file diff --git a/cmake/modules/test/libsimplecustomname/include/simple.h b/cmake/modules/test/libsimplecustomname/include/simple.h deleted file mode 100644 index 1449d6b212..0000000000 --- a/cmake/modules/test/libsimplecustomname/include/simple.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GUARD_SIMPLE_H -#define GUARD_SIMPLE_H - -inline void simple() { -} - - -#endif diff --git a/cmake/modules/test/libsimplecustomname/test.cpp b/cmake/modules/test/libsimplecustomname/test.cpp deleted file mode 100644 index c2a02710dc..0000000000 --- a/cmake/modules/test/libsimplecustomname/test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - simple(); -} diff --git a/cmake/modules/test/libsimplenamespace/CMakeLists.txt b/cmake/modules/test/libsimplenamespace/CMakeLists.txt deleted file mode 100644 index 96bf3b4bd1..0000000000 --- a/cmake/modules/test/libsimplenamespace/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(simple) - -find_package(CM) - -include(CMInstallTargets) -include(CMDeploy) -include(CMSetupVersion) -include(CMTest) - -cm_setup_version(VERSION 1.0) - -add_library(simple INTERFACE) -target_compile_definitions(simple INTERFACE -DHAS_SIMPLE=1) -cm_deploy(TARGETS simple include include NAMESPACE lib::) - -cm_test(NAME simpletest SOURCES test.cpp) -target_link_libraries(simpletest lib::simple) - -cm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) -target_link_libraries(simpletestcompile lib::simple) - -cm_test_header(NAME simpletestheader HEADER simple.h) -target_link_libraries(simpletestheader lib::simple) - -cm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) -target_link_libraries(simpleteststaticheader lib::simple) - diff --git a/cmake/modules/test/libsimplenamespace/compiletest.cpp b/cmake/modules/test/libsimplenamespace/compiletest.cpp deleted file mode 100644 index 081fde1f49..0000000000 --- a/cmake/modules/test/libsimplenamespace/compiletest.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -int main() { - std::abort(); - simple(); -} \ No newline at end of file diff --git a/cmake/modules/test/libsimplenamespace/include/simple.h b/cmake/modules/test/libsimplenamespace/include/simple.h deleted file mode 100644 index 24936d3f55..0000000000 --- a/cmake/modules/test/libsimplenamespace/include/simple.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef GUARD_SIMPLE_H -#define GUARD_SIMPLE_H - -#ifndef HAS_SIMPLE -#error "Not configured" -#endif - -inline void simple() { -} - - -#endif diff --git a/cmake/modules/test/libsimplenamespace/test.cpp b/cmake/modules/test/libsimplenamespace/test.cpp deleted file mode 100644 index c2a02710dc..0000000000 --- a/cmake/modules/test/libsimplenamespace/test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - simple(); -} diff --git a/cmake/modules/test/parseversion/CMakeLists.txt b/cmake/modules/test/parseversion/CMakeLists.txt deleted file mode 100644 index 5152778d81..0000000000 --- a/cmake/modules/test/parseversion/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(simple) - -find_package(CM) - -include(CMInstallTargets) -include(CMDeploy) -include(CMSetupVersion) -include(CMTest) - -cm_setup_version(PARSE_HEADER include/version.h) - -if(NOT "${PROJECT_VERSION}" STREQUAL "2.3.5") - message(SEND_ERROR "Incorrect version was parsed: ${PROJECT_VERSION}") -endif() - -add_library(simple INTERFACE) - -cm_install_targets(TARGETS simple include include) - -cm_test(NAME simpletest SOURCES test.cpp) -target_link_libraries(simpletest simple) - -cm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) -target_link_libraries(simpletestcompile simple) - -cm_test_header(NAME simpletestheader HEADER simple.h) -target_link_libraries(simpletestheader simple) - -cm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) -target_link_libraries(simpleteststaticheader simple) - diff --git a/cmake/modules/test/parseversion/compiletest.cpp b/cmake/modules/test/parseversion/compiletest.cpp deleted file mode 100644 index 081fde1f49..0000000000 --- a/cmake/modules/test/parseversion/compiletest.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -int main() { - std::abort(); - simple(); -} \ No newline at end of file diff --git a/cmake/modules/test/parseversion/include/simple.h b/cmake/modules/test/parseversion/include/simple.h deleted file mode 100644 index 8c6da42152..0000000000 --- a/cmake/modules/test/parseversion/include/simple.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef GUARD_SIMPLE_H -#define GUARD_SIMPLE_H - -#include "version.h" - -inline void simple() { -} - - -#endif diff --git a/cmake/modules/test/parseversion/include/version.h b/cmake/modules/test/parseversion/include/version.h deleted file mode 100644 index a1f525ba83..0000000000 --- a/cmake/modules/test/parseversion/include/version.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GUARD_VERSION_H -#define GUARD_VERSION_H - -#define SIMPLE_VERSION_MAJOR 2 -#define SIMPLE_VERSION_MINOR 3 -#define SIMPLE_VERSION_PATCH 5 - -#endif diff --git a/cmake/modules/test/parseversion/test.cpp b/cmake/modules/test/parseversion/test.cpp deleted file mode 100644 index c2a02710dc..0000000000 --- a/cmake/modules/test/parseversion/test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - simple(); -} diff --git a/cmake/modules/test/pass/basic.cmake b/cmake/modules/test/pass/basic.cmake deleted file mode 100644 index 6f989d2824..0000000000 --- a/cmake/modules/test/pass/basic.cmake +++ /dev/null @@ -1,6 +0,0 @@ -install_dir(${TEST_DIR}/libsimple TARGETS check) -install_dir(${TEST_DIR}/libbasic TARGETS check) -test_check_package(NAME simple HEADER simple.h TARGET simple) -test_check_pkgconfig(NAME simple HEADER simple.h) -test_check_package(NAME basic HEADER simple.h TARGET basic) -test_check_pkgconfig(NAME basic HEADER simple.h) diff --git a/cmake/modules/test/pass/defaultproperties.cmake b/cmake/modules/test/pass/defaultproperties.cmake deleted file mode 100644 index e2d941f10e..0000000000 --- a/cmake/modules/test/pass/defaultproperties.cmake +++ /dev/null @@ -1,15 +0,0 @@ -macro(check_prop PROP_NAME VAR_NAME PROP_VALUE) - build_dir(${TEST_DIR}/checkprop CMAKE_ARGS - -D${VAR_NAME}=${PROP_VALUE} - -DPROP_NAME=${PROP_NAME} - -DPROP_VALUE=${PROP_VALUE}) -endmacro() - -foreach(VALUE On Off 1 0) - check_prop(CXX_EXCEPTIONS CMAKE_CXX_EXCEPTIONS ${VALUE}) - check_prop(CXX_RTTI CMAKE_CXX_RTTI ${VALUE}) - check_prop(CXX_STATIC_RUNTIME CMAKE_CXX_STATIC_RUNTIME ${VALUE}) - check_prop(CXX_WARNINGS CMAKE_CXX_WARNINGS ${VALUE}) - check_prop(CXX_WARNINGS_AS_ERRORS CMAKE_CXX_WARNINGS_AS_ERRORS ${VALUE}) -endforeach() -check_prop(CXX_WARNINGS CMAKE_CXX_WARNINGS ALL) \ No newline at end of file diff --git a/cmake/modules/test/pass/parseversion.cmake b/cmake/modules/test/pass/parseversion.cmake deleted file mode 100644 index 8c2a3c2397..0000000000 --- a/cmake/modules/test/pass/parseversion.cmake +++ /dev/null @@ -1 +0,0 @@ -install_dir(${TEST_DIR}/parseversion TARGETS check) diff --git a/cmake/modules/test/pass/properties.cmake b/cmake/modules/test/pass/properties.cmake deleted file mode 100644 index 01f8ffa741..0000000000 --- a/cmake/modules/test/pass/properties.cmake +++ /dev/null @@ -1 +0,0 @@ -install_dir(${TEST_DIR}/properties TARGETS check) diff --git a/cmake/modules/test/pass/simple-shared.cmake b/cmake/modules/test/pass/simple-shared.cmake deleted file mode 100644 index 58a1b9c178..0000000000 --- a/cmake/modules/test/pass/simple-shared.cmake +++ /dev/null @@ -1,4 +0,0 @@ -install_dir(${TEST_DIR}/libsimple TARGETS check CMAKE_ARGS -DBUILD_SHARED_LIBS=On) -install_dir(${TEST_DIR}/basicapp TARGETS check CMAKE_ARGS -DBUILD_SHARED_LIBS=On) -test_check_package(NAME simple HEADER simple.h TARGET simple) -test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simple-test-build.cmake b/cmake/modules/test/pass/simple-test-build.cmake deleted file mode 100644 index 659f4adc9a..0000000000 --- a/cmake/modules/test/pass/simple-test-build.cmake +++ /dev/null @@ -1,3 +0,0 @@ -install_dir(${TEST_DIR}/simpletest TARGETS check CMAKE_ARGS -DBUILD_TESTING=On) -test_check_package(NAME simple HEADER simple.h TARGET simple) -test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simple-test-shared.cmake b/cmake/modules/test/pass/simple-test-shared.cmake deleted file mode 100644 index 4eee4fae1d..0000000000 --- a/cmake/modules/test/pass/simple-test-shared.cmake +++ /dev/null @@ -1,3 +0,0 @@ -install_dir(${TEST_DIR}/simpletest TARGETS check CMAKE_ARGS -DBUILD_SHARED_LIBS=On -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=On) -test_check_package(NAME simple HEADER simple.h TARGET simple CMAKE_ARGS -DBUILD_SHARED_LIBS=On -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=On) -test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simple-test.cmake b/cmake/modules/test/pass/simple-test.cmake deleted file mode 100644 index 11dec266d9..0000000000 --- a/cmake/modules/test/pass/simple-test.cmake +++ /dev/null @@ -1,3 +0,0 @@ -install_dir(${TEST_DIR}/simpletest TARGETS check) -test_check_package(NAME simple HEADER simple.h TARGET simple) -test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simple.cmake b/cmake/modules/test/pass/simple.cmake deleted file mode 100644 index 63a895ecb1..0000000000 --- a/cmake/modules/test/pass/simple.cmake +++ /dev/null @@ -1,4 +0,0 @@ -install_dir(${TEST_DIR}/libsimple TARGETS check) -install_dir(${TEST_DIR}/basicapp TARGETS check) -test_check_package(NAME simple HEADER simple.h TARGET simple) -test_check_pkgconfig(NAME simple HEADER simple.h) diff --git a/cmake/modules/test/pass/simplecustomname.cmake b/cmake/modules/test/pass/simplecustomname.cmake deleted file mode 100644 index 8325dfc001..0000000000 --- a/cmake/modules/test/pass/simplecustomname.cmake +++ /dev/null @@ -1,2 +0,0 @@ -install_dir(${TEST_DIR}/libsimplecustomname TARGETS check) -install_dir(${TEST_DIR}/libbasic TARGETS check) \ No newline at end of file diff --git a/cmake/modules/test/pass/simplenamespace.cmake b/cmake/modules/test/pass/simplenamespace.cmake deleted file mode 100644 index 079e737877..0000000000 --- a/cmake/modules/test/pass/simplenamespace.cmake +++ /dev/null @@ -1,2 +0,0 @@ -install_dir(${TEST_DIR}/libsimplenamespace TARGETS check) -test_check_package(NAME simple HEADER simple.h TARGET lib::simple) diff --git a/cmake/modules/test/pass/superproject.cmake b/cmake/modules/test/pass/superproject.cmake deleted file mode 100644 index 0cb7c103b7..0000000000 --- a/cmake/modules/test/pass/superproject.cmake +++ /dev/null @@ -1,5 +0,0 @@ -install_dir(${TEST_DIR}/superproject TARGETS check) -test_check_package(NAME simple HEADER simple.h TARGET lib::simple) -test_check_pkgconfig(NAME simple HEADER simple.h) -test_check_package(NAME basic HEADER simple.h TARGET lib::basic) -test_check_pkgconfig(NAME basic HEADER simple.h) \ No newline at end of file diff --git a/cmake/modules/test/pkgconfigcheck/CMakeLists.txt b/cmake/modules/test/pkgconfigcheck/CMakeLists.txt deleted file mode 100644 index 5f59a7b632..0000000000 --- a/cmake/modules/test/pkgconfigcheck/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(pkgconfigcheck) - -find_package(CM) - -include(CMInstallTargets) -include(CMDeploy) -include(CMSetupVersion) -include(CMTest) -include(CMPkgConfig) - -set(_pkgconfig_path) -foreach(PATH ${CMAKE_PREFIX_PATH}) - list(APPEND _pkgconfig_path ${PATH}/lib/pkgconfig) - list(APPEND _pkgconfig_path ${PATH}/share/pkgconfig) -endforeach() - -if(NOT "${_pkgconfig_path}" STREQUAL "") - # remove empty values from the list - list(REMOVE_ITEM _pkgconfig_path "") - file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path) - if(UNIX) - string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}") - string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}") - endif() - set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}") -endif() - -find_package(PkgConfig) -pkg_check_modules(PKGS REQUIRED ${PKG_CONFIG_MODULES}) - -cm_setup_version(VERSION 1.0 GENERATE_HEADER pkgconfigcheckversion.hpp) - -add_library(pkgconfigcheck INTERFACE) -target_compile_options(pkgconfigcheck INTERFACE ${PKGS_CFLAGS}) -target_link_libraries(pkgconfigcheck INTERFACE ${PKGS_LDFLAGS}) -cm_test_link_libraries(pkgconfigcheck) - -cm_install_targets(TARGETS pkgconfigcheck) -cm_auto_export(TARGETS pkgconfigcheck) - -if(DEFINED PKG_CONFIG_HEADER) - cm_test_header(NAME testheader HEADER ${PKG_CONFIG_HEADER}) - cm_test_header(NAME teststaticheader HEADER ${PKG_CONFIG_HEADER} STATIC) -endif() - diff --git a/cmake/modules/test/properties/CMakeLists.txt b/cmake/modules/test/properties/CMakeLists.txt deleted file mode 100644 index dd8c68453b..0000000000 --- a/cmake/modules/test/properties/CMakeLists.txt +++ /dev/null @@ -1,67 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(properties) - -find_package(CM) - -include(CMProperties) -include(CMSetupVersion) -include(CMDeploy) -include(CMTest) - -cm_setup_version(VERSION 1.0) - -add_library(simple INTERFACE) - -cm_install_targets(TARGETS simple include include) -cm_auto_export(TARGETS simple) -cm_auto_pkgconfig(TARGET simple) - -if(MSVC) - add_compile_options(/we4541) - add_compile_options(/we4530) -endif() - -cm_test_link_libraries(simple) - -cm_test(NAME simpletest SOURCES test.cpp) - -cm_test(NAME rttitest SOURCES test.cpp) -set_target_properties(rttitest PROPERTIES CXX_RTTI FALSE) - -cm_test(NAME exceptiontest SOURCES test.cpp) -set_target_properties(exceptiontest PROPERTIES CXX_EXCEPTIONS FALSE) - -cm_test(NAME statictest SOURCES test.cpp) -set_target_properties(statictest PROPERTIES CXX_STATIC_RUNTIME TRUE) - -cm_test(NAME throw SOURCES throw.cpp COMPILE_ONLY WILL_FAIL) -set_target_properties(throw PROPERTIES CXX_EXCEPTIONS FALSE) - -cm_test(NAME throwpass SOURCES throw.cpp) -set_target_properties(throwpass PROPERTIES CXX_EXCEPTIONS TRUE) - -cm_test(NAME rtti SOURCES rtti.cpp COMPILE_ONLY WILL_FAIL) -set_target_properties(rtti PROPERTIES CXX_RTTI FALSE) - -cm_test(NAME rttipass SOURCES rtti.cpp) -set_target_properties(rttipass PROPERTIES CXX_RTTI TRUE) - -foreach(WARNING_LEVEL FALSE TRUE all) - cm_test(NAME warnings-${WARNING_LEVEL} SOURCES warnings.cpp) - set_target_properties(warnings-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) - - if(WARNING_LEVEL STREQUAL "FALSE") - cm_test(NAME warnings-errors-${WARNING_LEVEL} SOURCES warnings.cpp COMPILE_ONLY) - else() - cm_test(NAME warnings-errors-${WARNING_LEVEL} SOURCES warnings.cpp COMPILE_ONLY WILL_FAIL) - endif() - set_target_properties(warnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) - set_target_properties(warnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS_AS_ERRORS TRUE) - - cm_test(NAME nowarnings-${WARNING_LEVEL} SOURCES nowarnings.cpp) - set_target_properties(nowarnings-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) - - cm_test(NAME nowarnings-errors-${WARNING_LEVEL} SOURCES nowarnings.cpp) - set_target_properties(nowarnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) - set_target_properties(nowarnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS_AS_ERRORS TRUE) -endforeach() diff --git a/cmake/modules/test/properties/include/simple.h b/cmake/modules/test/properties/include/simple.h deleted file mode 100644 index 1449d6b212..0000000000 --- a/cmake/modules/test/properties/include/simple.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GUARD_SIMPLE_H -#define GUARD_SIMPLE_H - -inline void simple() { -} - - -#endif diff --git a/cmake/modules/test/properties/nowarnings.cpp b/cmake/modules/test/properties/nowarnings.cpp deleted file mode 100644 index fe9ea520e4..0000000000 --- a/cmake/modules/test/properties/nowarnings.cpp +++ /dev/null @@ -1,5 +0,0 @@ -int main() { - // Unused variable - int i = 0; - (void) i; -} diff --git a/cmake/modules/test/properties/rtti.cpp b/cmake/modules/test/properties/rtti.cpp deleted file mode 100644 index c73196c4b0..0000000000 --- a/cmake/modules/test/properties/rtti.cpp +++ /dev/null @@ -1,20 +0,0 @@ -struct base { - virtual ~base() { - } -}; - -struct A : base { -}; - -struct B : base { -}; - -int main() { - base *x = new A(); - B *y = dynamic_cast(x); - if (y != 0) { - return -1; - } else { - return 0; - } -} diff --git a/cmake/modules/test/properties/test.cpp b/cmake/modules/test/properties/test.cpp deleted file mode 100644 index c2a02710dc..0000000000 --- a/cmake/modules/test/properties/test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - simple(); -} diff --git a/cmake/modules/test/properties/throw.cpp b/cmake/modules/test/properties/throw.cpp deleted file mode 100644 index 9dfc806303..0000000000 --- a/cmake/modules/test/properties/throw.cpp +++ /dev/null @@ -1,6 +0,0 @@ -int main() { - try { - throw "up"; - } catch (...) { - } -} diff --git a/cmake/modules/test/properties/warnings.cpp b/cmake/modules/test/properties/warnings.cpp deleted file mode 100644 index f13d2ed47b..0000000000 --- a/cmake/modules/test/properties/warnings.cpp +++ /dev/null @@ -1,9 +0,0 @@ -struct A; - -class A { -}; // C4099 - -int main() { - // Unused variable - int i = 0; -} diff --git a/cmake/modules/test/simpletest/CMakeLists.txt b/cmake/modules/test/simpletest/CMakeLists.txt deleted file mode 100644 index d19348cecd..0000000000 --- a/cmake/modules/test/simpletest/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(simple) - -find_package(CM) - -include(CMInstallTargets) -include(CMDeploy) -include(CMTest) -include(CMSetupVersion) - -cm_setup_version(VERSION 1.0) - -add_library(simple simple.cpp) -target_include_directories(simple PRIVATE $) - -cm_deploy(TARGETS simple include include) - -cm_test(NAME simpletoptest SOURCES test.cpp) -target_link_libraries(simpletoptest simple) - -cm_add_test_subdirectory(test) - -if(TARGET simpletest) - message(FATAL_ERROR "simpletest was not added") -endif() - diff --git a/cmake/modules/test/simpletest/include/simple.h b/cmake/modules/test/simpletest/include/simple.h deleted file mode 100644 index 84cc1a2e27..0000000000 --- a/cmake/modules/test/simpletest/include/simple.h +++ /dev/null @@ -1 +0,0 @@ -void simple(); diff --git a/cmake/modules/test/simpletest/simple.cpp b/cmake/modules/test/simpletest/simple.cpp deleted file mode 100644 index 88660cd7eb..0000000000 --- a/cmake/modules/test/simpletest/simple.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include - -void simple() { -} diff --git a/cmake/modules/test/simpletest/test.cpp b/cmake/modules/test/simpletest/test.cpp deleted file mode 100644 index c2a02710dc..0000000000 --- a/cmake/modules/test/simpletest/test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - simple(); -} diff --git a/cmake/modules/test/simpletest/test/CMakeLists.txt b/cmake/modules/test/simpletest/test/CMakeLists.txt deleted file mode 100644 index d4b91e9048..0000000000 --- a/cmake/modules/test/simpletest/test/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cm_test_link_libraries(simple) - -if(NOT BUILD_TESTING) - cm_test_link_libraries(foo::non_existent) -endif() - -cm_test(NAME simpletest SOURCES test.cpp) diff --git a/cmake/modules/test/simpletest/test/test.cpp b/cmake/modules/test/simpletest/test/test.cpp deleted file mode 100644 index c2a02710dc..0000000000 --- a/cmake/modules/test/simpletest/test/test.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - simple(); -} diff --git a/cmake/modules/test/superproject/CMakeLists.txt b/cmake/modules/test/superproject/CMakeLists.txt deleted file mode 100644 index 8ce520d9d5..0000000000 --- a/cmake/modules/test/superproject/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(superproject) - -find_package(CM) -include(CMIgnorePackage) - -cm_ignore_package(simple) - -add_subdirectory(../libbasicnamespace libbasicnamespace) -add_subdirectory(../libsimplenamespace libsimplenamespace) diff --git a/cmake/modules/test/test.cmake b/cmake/modules/test/test.cmake deleted file mode 100644 index ec6c355d94..0000000000 --- a/cmake/modules/test/test.cmake +++ /dev/null @@ -1,124 +0,0 @@ - -if(CMAKE_ARGC LESS 5) - message(FATAL_ERROR "Not enough parameters to test.cmake") -endif() - -math(EXPR TMP_ARGN "${CMAKE_ARGC}-1") -math(EXPR TEST_ARGN "${TMP_ARGN}-1") - -string(RANDOM _TEST_RAND) -set(TEST ${CMAKE_ARGV${TEST_ARGN}}) -set(TEST_DIR .) -set(TMP_DIR ${CMAKE_ARGV${TMP_ARGN}}-${_TEST_RAND}) -file(MAKE_DIRECTORY ${TMP_DIR}) -set(PREFIX ${TMP_DIR}/usr) -set(BUILDS_DIR ${TMP_DIR}/builds) -# message("TMP_DIR: ${TMP_DIR}") - -if(NOT EXISTS ${TEST}) - message(FATAL_ERROR "Test ${TEST} does not exist") -endif() - -macro(test_expect_eq X Y) - if(NOT ${X} EQUAL ${Y}) - message(FATAL_ERROR "EXPECT FAILURE: ${X} != ${Y}") - endif() -endmacro() - -macro(test_expect_file FILE) - if(NOT EXISTS ${FILE}) - message(FATAL_ERROR "EXPECT FILE: ${FILE}") - endif() -endmacro() - -function(test_exec) - string(REPLACE ";" " " OUTPUT "${ARGN}") - message(${OUTPUT}) - execute_process(${ARGN} RESULT_VARIABLE RESULT) - if(NOT RESULT EQUAL 0) - message(FATAL_ERROR "Process failed: ${OUTPUT}") - endif() -endfunction() - -function(install_dir DIR) - set(options NO_INSTALL) - set(oneValueArgs) - set(multiValueArgs CMAKE_ARGS TARGETS) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - string(RANDOM BUILD_RAND) - set(BUILD_DIR ${BUILDS_DIR}/${BUILD_RAND}) - if(NOT EXISTS ${BUILD_DIR}) - file(MAKE_DIRECTORY ${BUILD_DIR}) - endif() - if(CMAKE_TOOLCHAIN_FILE) - set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") - endif() - test_exec(COMMAND ${CMAKE_COMMAND} - -DCMAKE_PREFIX_PATH=${PREFIX} - -DCMAKE_INSTALL_PREFIX=${PREFIX} - -DTHREADS_PREFER_PTHREAD_FLAG=1 - ${TOOLCHAIN_ARG} - ${PARSE_CMAKE_ARGS} - ${DIR} - WORKING_DIRECTORY ${BUILD_DIR} - ) - test_exec(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR}) - foreach(TARGET ${PARSE_TARGETS}) - test_exec(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR} --target ${TARGET}) - endforeach() - if(NOT PARSE_NO_INSTALL) - test_exec(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR} --target install) - endif() - - file(REMOVE_RECURSE ${BUILD_DIR}) -endfunction() - -function(build_dir DIR) - install_dir(${DIR} ${ARGN} NO_INSTALL) -endfunction() - -function(test_check_pkgconfig) - set(options) - set(oneValueArgs NAME HEADER) - set(multiValueArgs) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(HEADER_FLAG) - if(PARSE_HEADER) - set(HEADER_FLAG -DPKG_CONFIG_HEADER=${PARSE_HEADER}) - endif() - - # TODO: We really should check pkgconfig during cross compiling - if(NOT CMAKE_CROSSCOMPILING) - install_dir(${TEST_DIR}/pkgconfigcheck TARGETS check CMAKE_ARGS -DPKG_CONFIG_MODULES=${PARSE_NAME} ${HEADER_FLAG}) - endif() -endfunction() - -function(test_check_package) - set(options) - set(oneValueArgs NAME HEADER TARGET) - set(multiValueArgs) - - cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(HEADER_FLAG) - if(PARSE_HEADER) - set(HEADER_FLAG -DPKG_HEADER=${PARSE_HEADER}) - endif() - - set(TARGET ${PARSE_NAME}) - if(PARSE_TARGET) - set(TARGET ${PARSE_TARGET}) - endif() - - install_dir(${TEST_DIR}/findpackagecheck CMAKE_ARGS -DPKG=${PARSE_NAME} -DPKG_TARGET=${TARGET} ${HEADER_FLAG}) -endfunction() - -install_dir(${TEST_DIR}/../) - -include(${TEST}) - -file(REMOVE_RECURSE ${TMP_DIR}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index be92abaa9f..8bd2a2d0c3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,7 +26,7 @@ include(CMTest) if(NOT Boost_UNIT_TEST_FRAMEWORK_FOUND) - cm_find_package(Boost REQUIRED COMPONENTS unit_test_framework) + find_package(Boost REQUIRED COMPONENTS unit_test_framework) endif() cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} From 39e2c812d375e8bcb662edd6661a8c26c50eb723 Mon Sep 17 00:00:00 2001 From: x-mass <36629999+x-mass@users.noreply.github.com> Date: Thu, 6 Jun 2024 07:53:01 +0000 Subject: [PATCH 20/23] Link tests to Boost::random instead of ${Boost_LIBRARIES} --- test/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8bd2a2d0c3..6451bb7284 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,16 +25,12 @@ include(CMTest) -if(NOT Boost_UNIT_TEST_FRAMEWORK_FOUND) - find_package(Boost REQUIRED COMPONENTS unit_test_framework) -endif() - cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} crypto3::algebra crypto3::hash - ${Boost_LIBRARIES}) + Boost::random) macro(define_storage_test test) get_filename_component(test_name ${test} NAME) From 6cf1c961e9527df5096c032355c492c250f13ee4 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Fri, 7 Jun 2024 12:34:03 +0200 Subject: [PATCH 21/23] Move all files into libs/parallel-containers directory --- .clang-format => libs/parallel-containers/.clang-format | 0 .gitignore => libs/parallel-containers/.gitignore | 0 CMakeLists.txt => libs/parallel-containers/CMakeLists.txt | 0 LICENSE_1_0.txt => libs/parallel-containers/LICENSE_1_0.txt | 0 README.md => libs/parallel-containers/README.md | 0 {cmake => libs/parallel-containers/cmake}/CheckAVX.cmake | 0 {cmake => libs/parallel-containers/cmake}/CheckSSE.cmake | 0 .../parallel-containers/cmake}/PlatformConfiguration.cmake | 0 .../parallel-containers/cmake}/TargetArchitecture.cmake | 0 .../parallel-containers/cmake}/TargetConfiguration.cmake | 0 .../parallel-containers/cmake}/architectures/alpha.json | 0 .../parallel-containers/cmake}/architectures/arm32.json | 0 .../parallel-containers/cmake}/architectures/arm64.json | 0 {cmake => libs/parallel-containers/cmake}/architectures/hppa.json | 0 {cmake => libs/parallel-containers/cmake}/architectures/ia64.json | 0 {cmake => libs/parallel-containers/cmake}/architectures/llvm.json | 0 {cmake => libs/parallel-containers/cmake}/architectures/m68k.json | 0 .../parallel-containers/cmake}/architectures/mips32.json | 0 .../parallel-containers/cmake}/architectures/mips64.json | 0 .../parallel-containers/cmake}/architectures/powerpcspe.json | 0 .../parallel-containers/cmake}/architectures/ppc32.json | 0 .../parallel-containers/cmake}/architectures/ppc64.json | 0 .../parallel-containers/cmake}/architectures/riscv64.json | 0 {cmake => libs/parallel-containers/cmake}/architectures/s390.json | 0 .../parallel-containers/cmake}/architectures/s390x.json | 0 .../parallel-containers/cmake}/architectures/sparc32.json | 0 .../parallel-containers/cmake}/architectures/sparc64.json | 0 .../parallel-containers/cmake}/architectures/superh.json | 0 {cmake => libs/parallel-containers/cmake}/architectures/x32.json | 0 .../parallel-containers/cmake}/architectures/x86_32.json | 0 .../parallel-containers/cmake}/architectures/x86_64.json | 0 .../parallel-containers/cmake}/packages/FindCrypto3.cmake | 0 .../parallel-containers/cmake}/packages/FindValgrind.cmake | 0 {example => libs/parallel-containers/example}/CMakeLists.txt | 0 {example => libs/parallel-containers/example}/merkle/merkle.cpp | 0 .../include}/nil/crypto3/container/accumulation_vector.hpp | 0 .../include}/nil/crypto3/container/merkle/node.hpp | 0 .../include}/nil/crypto3/container/merkle/proof.hpp | 0 .../include}/nil/crypto3/container/merkle/tree.hpp | 0 .../include}/nil/crypto3/container/sparse_vector.hpp | 0 {test => libs/parallel-containers/test}/CMakeLists.txt | 0 {test => libs/parallel-containers/test}/merkle/merkle.cpp | 0 42 files changed, 0 insertions(+), 0 deletions(-) rename .clang-format => libs/parallel-containers/.clang-format (100%) rename .gitignore => libs/parallel-containers/.gitignore (100%) rename CMakeLists.txt => libs/parallel-containers/CMakeLists.txt (100%) rename LICENSE_1_0.txt => libs/parallel-containers/LICENSE_1_0.txt (100%) rename README.md => libs/parallel-containers/README.md (100%) rename {cmake => libs/parallel-containers/cmake}/CheckAVX.cmake (100%) rename {cmake => libs/parallel-containers/cmake}/CheckSSE.cmake (100%) rename {cmake => libs/parallel-containers/cmake}/PlatformConfiguration.cmake (100%) rename {cmake => libs/parallel-containers/cmake}/TargetArchitecture.cmake (100%) rename {cmake => libs/parallel-containers/cmake}/TargetConfiguration.cmake (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/alpha.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/arm32.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/arm64.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/hppa.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/ia64.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/llvm.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/m68k.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/mips32.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/mips64.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/powerpcspe.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/ppc32.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/ppc64.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/riscv64.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/s390.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/s390x.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/sparc32.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/sparc64.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/superh.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/x32.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/x86_32.json (100%) rename {cmake => libs/parallel-containers/cmake}/architectures/x86_64.json (100%) rename {cmake => libs/parallel-containers/cmake}/packages/FindCrypto3.cmake (100%) rename {cmake => libs/parallel-containers/cmake}/packages/FindValgrind.cmake (100%) rename {example => libs/parallel-containers/example}/CMakeLists.txt (100%) rename {example => libs/parallel-containers/example}/merkle/merkle.cpp (100%) rename {include => libs/parallel-containers/include}/nil/crypto3/container/accumulation_vector.hpp (100%) rename {include => libs/parallel-containers/include}/nil/crypto3/container/merkle/node.hpp (100%) rename {include => libs/parallel-containers/include}/nil/crypto3/container/merkle/proof.hpp (100%) rename {include => libs/parallel-containers/include}/nil/crypto3/container/merkle/tree.hpp (100%) rename {include => libs/parallel-containers/include}/nil/crypto3/container/sparse_vector.hpp (100%) rename {test => libs/parallel-containers/test}/CMakeLists.txt (100%) rename {test => libs/parallel-containers/test}/merkle/merkle.cpp (100%) diff --git a/.clang-format b/libs/parallel-containers/.clang-format similarity index 100% rename from .clang-format rename to libs/parallel-containers/.clang-format diff --git a/.gitignore b/libs/parallel-containers/.gitignore similarity index 100% rename from .gitignore rename to libs/parallel-containers/.gitignore diff --git a/CMakeLists.txt b/libs/parallel-containers/CMakeLists.txt similarity index 100% rename from CMakeLists.txt rename to libs/parallel-containers/CMakeLists.txt diff --git a/LICENSE_1_0.txt b/libs/parallel-containers/LICENSE_1_0.txt similarity index 100% rename from LICENSE_1_0.txt rename to libs/parallel-containers/LICENSE_1_0.txt diff --git a/README.md b/libs/parallel-containers/README.md similarity index 100% rename from README.md rename to libs/parallel-containers/README.md diff --git a/cmake/CheckAVX.cmake b/libs/parallel-containers/cmake/CheckAVX.cmake similarity index 100% rename from cmake/CheckAVX.cmake rename to libs/parallel-containers/cmake/CheckAVX.cmake diff --git a/cmake/CheckSSE.cmake b/libs/parallel-containers/cmake/CheckSSE.cmake similarity index 100% rename from cmake/CheckSSE.cmake rename to libs/parallel-containers/cmake/CheckSSE.cmake diff --git a/cmake/PlatformConfiguration.cmake b/libs/parallel-containers/cmake/PlatformConfiguration.cmake similarity index 100% rename from cmake/PlatformConfiguration.cmake rename to libs/parallel-containers/cmake/PlatformConfiguration.cmake diff --git a/cmake/TargetArchitecture.cmake b/libs/parallel-containers/cmake/TargetArchitecture.cmake similarity index 100% rename from cmake/TargetArchitecture.cmake rename to libs/parallel-containers/cmake/TargetArchitecture.cmake diff --git a/cmake/TargetConfiguration.cmake b/libs/parallel-containers/cmake/TargetConfiguration.cmake similarity index 100% rename from cmake/TargetConfiguration.cmake rename to libs/parallel-containers/cmake/TargetConfiguration.cmake diff --git a/cmake/architectures/alpha.json b/libs/parallel-containers/cmake/architectures/alpha.json similarity index 100% rename from cmake/architectures/alpha.json rename to libs/parallel-containers/cmake/architectures/alpha.json diff --git a/cmake/architectures/arm32.json b/libs/parallel-containers/cmake/architectures/arm32.json similarity index 100% rename from cmake/architectures/arm32.json rename to libs/parallel-containers/cmake/architectures/arm32.json diff --git a/cmake/architectures/arm64.json b/libs/parallel-containers/cmake/architectures/arm64.json similarity index 100% rename from cmake/architectures/arm64.json rename to libs/parallel-containers/cmake/architectures/arm64.json diff --git a/cmake/architectures/hppa.json b/libs/parallel-containers/cmake/architectures/hppa.json similarity index 100% rename from cmake/architectures/hppa.json rename to libs/parallel-containers/cmake/architectures/hppa.json diff --git a/cmake/architectures/ia64.json b/libs/parallel-containers/cmake/architectures/ia64.json similarity index 100% rename from cmake/architectures/ia64.json rename to libs/parallel-containers/cmake/architectures/ia64.json diff --git a/cmake/architectures/llvm.json b/libs/parallel-containers/cmake/architectures/llvm.json similarity index 100% rename from cmake/architectures/llvm.json rename to libs/parallel-containers/cmake/architectures/llvm.json diff --git a/cmake/architectures/m68k.json b/libs/parallel-containers/cmake/architectures/m68k.json similarity index 100% rename from cmake/architectures/m68k.json rename to libs/parallel-containers/cmake/architectures/m68k.json diff --git a/cmake/architectures/mips32.json b/libs/parallel-containers/cmake/architectures/mips32.json similarity index 100% rename from cmake/architectures/mips32.json rename to libs/parallel-containers/cmake/architectures/mips32.json diff --git a/cmake/architectures/mips64.json b/libs/parallel-containers/cmake/architectures/mips64.json similarity index 100% rename from cmake/architectures/mips64.json rename to libs/parallel-containers/cmake/architectures/mips64.json diff --git a/cmake/architectures/powerpcspe.json b/libs/parallel-containers/cmake/architectures/powerpcspe.json similarity index 100% rename from cmake/architectures/powerpcspe.json rename to libs/parallel-containers/cmake/architectures/powerpcspe.json diff --git a/cmake/architectures/ppc32.json b/libs/parallel-containers/cmake/architectures/ppc32.json similarity index 100% rename from cmake/architectures/ppc32.json rename to libs/parallel-containers/cmake/architectures/ppc32.json diff --git a/cmake/architectures/ppc64.json b/libs/parallel-containers/cmake/architectures/ppc64.json similarity index 100% rename from cmake/architectures/ppc64.json rename to libs/parallel-containers/cmake/architectures/ppc64.json diff --git a/cmake/architectures/riscv64.json b/libs/parallel-containers/cmake/architectures/riscv64.json similarity index 100% rename from cmake/architectures/riscv64.json rename to libs/parallel-containers/cmake/architectures/riscv64.json diff --git a/cmake/architectures/s390.json b/libs/parallel-containers/cmake/architectures/s390.json similarity index 100% rename from cmake/architectures/s390.json rename to libs/parallel-containers/cmake/architectures/s390.json diff --git a/cmake/architectures/s390x.json b/libs/parallel-containers/cmake/architectures/s390x.json similarity index 100% rename from cmake/architectures/s390x.json rename to libs/parallel-containers/cmake/architectures/s390x.json diff --git a/cmake/architectures/sparc32.json b/libs/parallel-containers/cmake/architectures/sparc32.json similarity index 100% rename from cmake/architectures/sparc32.json rename to libs/parallel-containers/cmake/architectures/sparc32.json diff --git a/cmake/architectures/sparc64.json b/libs/parallel-containers/cmake/architectures/sparc64.json similarity index 100% rename from cmake/architectures/sparc64.json rename to libs/parallel-containers/cmake/architectures/sparc64.json diff --git a/cmake/architectures/superh.json b/libs/parallel-containers/cmake/architectures/superh.json similarity index 100% rename from cmake/architectures/superh.json rename to libs/parallel-containers/cmake/architectures/superh.json diff --git a/cmake/architectures/x32.json b/libs/parallel-containers/cmake/architectures/x32.json similarity index 100% rename from cmake/architectures/x32.json rename to libs/parallel-containers/cmake/architectures/x32.json diff --git a/cmake/architectures/x86_32.json b/libs/parallel-containers/cmake/architectures/x86_32.json similarity index 100% rename from cmake/architectures/x86_32.json rename to libs/parallel-containers/cmake/architectures/x86_32.json diff --git a/cmake/architectures/x86_64.json b/libs/parallel-containers/cmake/architectures/x86_64.json similarity index 100% rename from cmake/architectures/x86_64.json rename to libs/parallel-containers/cmake/architectures/x86_64.json diff --git a/cmake/packages/FindCrypto3.cmake b/libs/parallel-containers/cmake/packages/FindCrypto3.cmake similarity index 100% rename from cmake/packages/FindCrypto3.cmake rename to libs/parallel-containers/cmake/packages/FindCrypto3.cmake diff --git a/cmake/packages/FindValgrind.cmake b/libs/parallel-containers/cmake/packages/FindValgrind.cmake similarity index 100% rename from cmake/packages/FindValgrind.cmake rename to libs/parallel-containers/cmake/packages/FindValgrind.cmake diff --git a/example/CMakeLists.txt b/libs/parallel-containers/example/CMakeLists.txt similarity index 100% rename from example/CMakeLists.txt rename to libs/parallel-containers/example/CMakeLists.txt diff --git a/example/merkle/merkle.cpp b/libs/parallel-containers/example/merkle/merkle.cpp similarity index 100% rename from example/merkle/merkle.cpp rename to libs/parallel-containers/example/merkle/merkle.cpp diff --git a/include/nil/crypto3/container/accumulation_vector.hpp b/libs/parallel-containers/include/nil/crypto3/container/accumulation_vector.hpp similarity index 100% rename from include/nil/crypto3/container/accumulation_vector.hpp rename to libs/parallel-containers/include/nil/crypto3/container/accumulation_vector.hpp diff --git a/include/nil/crypto3/container/merkle/node.hpp b/libs/parallel-containers/include/nil/crypto3/container/merkle/node.hpp similarity index 100% rename from include/nil/crypto3/container/merkle/node.hpp rename to libs/parallel-containers/include/nil/crypto3/container/merkle/node.hpp diff --git a/include/nil/crypto3/container/merkle/proof.hpp b/libs/parallel-containers/include/nil/crypto3/container/merkle/proof.hpp similarity index 100% rename from include/nil/crypto3/container/merkle/proof.hpp rename to libs/parallel-containers/include/nil/crypto3/container/merkle/proof.hpp diff --git a/include/nil/crypto3/container/merkle/tree.hpp b/libs/parallel-containers/include/nil/crypto3/container/merkle/tree.hpp similarity index 100% rename from include/nil/crypto3/container/merkle/tree.hpp rename to libs/parallel-containers/include/nil/crypto3/container/merkle/tree.hpp diff --git a/include/nil/crypto3/container/sparse_vector.hpp b/libs/parallel-containers/include/nil/crypto3/container/sparse_vector.hpp similarity index 100% rename from include/nil/crypto3/container/sparse_vector.hpp rename to libs/parallel-containers/include/nil/crypto3/container/sparse_vector.hpp diff --git a/test/CMakeLists.txt b/libs/parallel-containers/test/CMakeLists.txt similarity index 100% rename from test/CMakeLists.txt rename to libs/parallel-containers/test/CMakeLists.txt diff --git a/test/merkle/merkle.cpp b/libs/parallel-containers/test/merkle/merkle.cpp similarity index 100% rename from test/merkle/merkle.cpp rename to libs/parallel-containers/test/merkle/merkle.cpp From 1c79bcc6537c3e87f678b5c982ad1f47d5311d99 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Fri, 7 Jun 2024 14:06:19 +0200 Subject: [PATCH 22/23] Remove parallel-containers submodule --- .gitmodules | 3 --- libs/parallel-containers | 1 - 2 files changed, 4 deletions(-) delete mode 160000 libs/parallel-containers diff --git a/.gitmodules b/.gitmodules index db7cb32d5b..9076ca5fc9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,6 @@ [submodule "libs/threaded-math"] path = libs/parallel-math url = git@github.com:NilFoundation/actor-math -[submodule "libs/threaded-containers"] - path = libs/parallel-containers - url = git@github.com:NilFoundation/actor-containers [submodule "cmake/modules"] path = cmake/modules url = git@github.com:BoostCMake/cmake_modules.git diff --git a/libs/parallel-containers b/libs/parallel-containers deleted file mode 160000 index 39e2c812d3..0000000000 --- a/libs/parallel-containers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 39e2c812d375e8bcb662edd6661a8c26c50eb723 From 56dfb4c0ea120b014af83549dc358a4695acee3c Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Fri, 7 Jun 2024 14:08:02 +0200 Subject: [PATCH 23/23] cleanup .git* files and submodules in ex-parallel-containers submodule --- libs/parallel-containers/.clang-format | 94 --- libs/parallel-containers/.gitignore | 632 ------------------ libs/parallel-containers/LICENSE_1_0.txt | 21 - libs/parallel-containers/cmake/CheckAVX.cmake | 63 -- libs/parallel-containers/cmake/CheckSSE.cmake | 138 ---- .../cmake/PlatformConfiguration.cmake | 141 ---- .../cmake/TargetArchitecture.cmake | 163 ----- .../cmake/TargetConfiguration.cmake | 6 - .../cmake/architectures/alpha.json | 8 - .../cmake/architectures/arm32.json | 16 - .../cmake/architectures/arm64.json | 19 - .../cmake/architectures/hppa.json | 12 - .../cmake/architectures/ia64.json | 7 - .../cmake/architectures/llvm.json | 4 - .../cmake/architectures/m68k.json | 8 - .../cmake/architectures/mips32.json | 10 - .../cmake/architectures/mips64.json | 7 - .../cmake/architectures/powerpcspe.json | 5 - .../cmake/architectures/ppc32.json | 12 - .../cmake/architectures/ppc64.json | 15 - .../cmake/architectures/riscv64.json | 5 - .../cmake/architectures/s390.json | 4 - .../cmake/architectures/s390x.json | 4 - .../cmake/architectures/sparc32.json | 8 - .../cmake/architectures/sparc64.json | 5 - .../cmake/architectures/superh.json | 7 - .../cmake/architectures/x32.json | 17 - .../cmake/architectures/x86_32.json | 30 - .../cmake/architectures/x86_64.json | 24 - .../cmake/packages/FindCrypto3.cmake | 0 .../cmake/packages/FindValgrind.cmake | 23 - 31 files changed, 1508 deletions(-) delete mode 100644 libs/parallel-containers/.clang-format delete mode 100644 libs/parallel-containers/.gitignore delete mode 100644 libs/parallel-containers/LICENSE_1_0.txt delete mode 100644 libs/parallel-containers/cmake/CheckAVX.cmake delete mode 100644 libs/parallel-containers/cmake/CheckSSE.cmake delete mode 100644 libs/parallel-containers/cmake/PlatformConfiguration.cmake delete mode 100644 libs/parallel-containers/cmake/TargetArchitecture.cmake delete mode 100644 libs/parallel-containers/cmake/TargetConfiguration.cmake delete mode 100644 libs/parallel-containers/cmake/architectures/alpha.json delete mode 100644 libs/parallel-containers/cmake/architectures/arm32.json delete mode 100644 libs/parallel-containers/cmake/architectures/arm64.json delete mode 100644 libs/parallel-containers/cmake/architectures/hppa.json delete mode 100644 libs/parallel-containers/cmake/architectures/ia64.json delete mode 100644 libs/parallel-containers/cmake/architectures/llvm.json delete mode 100644 libs/parallel-containers/cmake/architectures/m68k.json delete mode 100644 libs/parallel-containers/cmake/architectures/mips32.json delete mode 100644 libs/parallel-containers/cmake/architectures/mips64.json delete mode 100644 libs/parallel-containers/cmake/architectures/powerpcspe.json delete mode 100644 libs/parallel-containers/cmake/architectures/ppc32.json delete mode 100644 libs/parallel-containers/cmake/architectures/ppc64.json delete mode 100644 libs/parallel-containers/cmake/architectures/riscv64.json delete mode 100644 libs/parallel-containers/cmake/architectures/s390.json delete mode 100644 libs/parallel-containers/cmake/architectures/s390x.json delete mode 100644 libs/parallel-containers/cmake/architectures/sparc32.json delete mode 100644 libs/parallel-containers/cmake/architectures/sparc64.json delete mode 100644 libs/parallel-containers/cmake/architectures/superh.json delete mode 100644 libs/parallel-containers/cmake/architectures/x32.json delete mode 100644 libs/parallel-containers/cmake/architectures/x86_32.json delete mode 100644 libs/parallel-containers/cmake/architectures/x86_64.json delete mode 100644 libs/parallel-containers/cmake/packages/FindCrypto3.cmake delete mode 100644 libs/parallel-containers/cmake/packages/FindValgrind.cmake diff --git a/libs/parallel-containers/.clang-format b/libs/parallel-containers/.clang-format deleted file mode 100644 index 3efc3f0e7f..0000000000 --- a/libs/parallel-containers/.clang-format +++ /dev/null @@ -1,94 +0,0 @@ ---- -BasedOnStyle: WebKit -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Left -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: Never -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: true -BinPackParameters: true -BreakAfterJavaFieldAnnotations: true -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: false -BreakConstructorInitializers: AfterColon -BreakStringLiterals: true -ColumnLimit: 120 -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: true -FixNamespaceComments: true -ForEachMacros: ['BOOST_FOREACH'] -IncludeBlocks: Regroup -IncludeCategories: - - Regex: '^"(<)/' - Priority: 1 - - Regex: '^(<(boost)/)' - Priority: 2 - - Regex: '^(<(nil\/crypto3)/)' - Priority: 3 - - Regex: '.*' - Priority: 4 -IndentCaseLabels: true -IndentPPDirectives: None -IndentWidth: 4 -IndentWrappedFunctionNames: true -KeepEmptyLinesAtTheStartOfBlocks: true -Language: Cpp -NamespaceIndentation: All -ObjCBlockIndentWidth: 4 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true -PointerAlignment: Right -ReflowComments: true -SortIncludes: false -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 4 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: true -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: c++11 -TabWidth: 4 -UseTab: Never - -... diff --git a/libs/parallel-containers/.gitignore b/libs/parallel-containers/.gitignore deleted file mode 100644 index 26d47ea724..0000000000 --- a/libs/parallel-containers/.gitignore +++ /dev/null @@ -1,632 +0,0 @@ -## Core latex/pdflatex auxiliary files: -*.aux -*.lof -*.log -*.lot -*.fls -*.out -*.toc -*.fmt -*.fot -*.cb -*.cb2 -.*.lb - -## Intermediate documents: -*.dvi -*.xdv -*-converted-to.* -# these rules might exclude image files for figures etc. -# *.ps -# *.eps -# *.pdf - -## Generated if empty string is given at "Please type another file name for output:" -.pdf - -## Bibliography auxiliary files (bibtex/biblatex/biber): -*.bbl -*.bcf -*.blg -*-blx.aux -*-blx.bib -*.run.xml - -## Build tool auxiliary files: -*.fdb_latexmk -*.synctex -*.synctex(busy) -*.synctex.gz -*.synctex.gz(busy) -*.pdfsync - -## Auxiliary and intermediate files from other packages: -# algorithms -*.alg -*.loa - -# achemso -acs-*.bib - -# amsthm -*.thm - -# beamer -*.nav -*.pre -*.snm -*.vrb - -# changes -*.soc - -# cprotect -*.cpt - -# elsarticle (documentclass of Elsevier journals) -*.spl - -# endnotes -*.ent - -# fixme -*.lox - -# feynmf/feynmp -*.mf -*.mp -*.t[1-9] -*.t[1-9][0-9] -*.tfm - -#(r)(e)ledmac/(r)(e)ledpar -*.end -*.?end -*.[1-9] -*.[1-9][0-9] -*.[1-9][0-9][0-9] -*.[1-9]R -*.[1-9][0-9]R -*.[1-9][0-9][0-9]R -*.eledsec[1-9] -*.eledsec[1-9]R -*.eledsec[1-9][0-9] -*.eledsec[1-9][0-9]R -*.eledsec[1-9][0-9][0-9] -*.eledsec[1-9][0-9][0-9]R - -# glossaries -*.acn -*.acr -*.glg -*.glo -*.gls -*.glsdefs - -# gnuplottex -*-gnuplottex-* - -# gregoriotex -*.gaux -*.gtex - -# htlatex -*.4ct -*.4tc -*.idv -*.lg -*.trc -*.xref - -# hyperref -*.brf - -# knitr -*-concordance.tex -# TODO Comment the next line if you want to keep your tikz graphics files -*.tikz -*-tikzDictionary - -# listings -*.lol - -# makeidx -*.idx -*.ilg -*.ind -*.ist - -# minitoc -*.maf -*.mlf -*.mlt -*.mtc[0-9]* -*.slf[0-9]* -*.slt[0-9]* -*.stc[0-9]* - -# minted -_minted* -*.pyg - -# morewrites -*.mw - -# nomencl -*.nlg -*.nlo -*.nls - -# pax -*.pax - -# pdfpcnotes -*.pdfpc - -# sagetex -*.sagetex.sage -*.sagetex.py -*.sagetex.scmd - -# scrwfile -*.wrt - -# sympy -*.sout -*.sympy -sympy-plots-for-*.tex/ - -# pdfcomment -*.upa -*.upb - -# pythontex -*.pytxcode -pythontex-files-*/ - -# thmtools -*.loe - -# TikZ & PGF -*.dpth -*.md5 -*.auxlock - -# todonotes -*.tdo - -# easy-todo -*.lod - -# xmpincl -*.xmpi - -# xindy -*.xdy - -# xypic precompiled matrices -*.xyc - -# endfloat -*.ttt -*.fff - -# Latexian -TSWLatexianTemp* - -## Editors: -# WinEdt -*.bak -*.sav - -# Texpad -.texpadtmp - -# Kile -*.backup - -# KBibTeX -*~[0-9]* - -# auto folder when using emacs and auctex -./auto/* -*.el - -# expex forward references with \gathertags -*-tags.tex - -# standalone packages -*.sta - -### C++ ### -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -### CLion+all ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries - -# CMake -cmake-build-debug/ - -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Ruby plugin and RubyMine -/.rakeTasks - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -### CLion+all Patch ### -# Ignores the whole .idea folder and all .iml files -# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 - -.idea/ - -# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 - -*.iml -modules.xml -.idea/misc.xml -*.ipr - -### CMake ### -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -build - -### LaTeX ### -## Core latex/pdflatex auxiliary files: -*.aux -*.lof -*.log -*.lot -*.fls -*.toc -*.fmt -*.fot -*.cb -*.cb2 - -## Intermediate documents: -*.dvi -*.xdv -*-converted-to.* -# these rules might exclude image files for figures etc. -# *.ps -# *.eps -# *.pdf - -## Generated if empty string is given at "Please type another file name for output:" -.pdf - -## Bibliography auxiliary files (bibtex/biblatex/biber): -*.bbl -*.bcf -*.blg -*-blx.aux -*-blx.bib -*.run.xml - -## Build tool auxiliary files: -*.fdb_latexmk -*.synctex -*.synctex(busy) -*.synctex.gz -*.synctex.gz(busy) -*.pdfsync -*Notes.bib - -## Auxiliary and intermediate files from other packages: -# algorithms -*.alg -*.loa - -# achemso -acs-*.bib - -# amsthm -*.thm - -# beamer -*.nav -*.pre -*.snm -*.vrb - -# changes -*.soc - -# cprotect -*.cpt - -# elsarticle (documentclass of Elsevier journals) -*.spl - -# endnotes -*.ent - -# fixme -*.lox - -# feynmf/feynmp -*.mf -*.mp -*.t[1-9] -*.t[1-9][0-9] -*.tfm - -#(r)(e)ledmac/(r)(e)ledpar -*.end -*.?end -*.[1-9] -*.[1-9][0-9] -*.[1-9][0-9][0-9] -*.[1-9]R -*.[1-9][0-9]R -*.[1-9][0-9][0-9]R -*.eledsec[1-9] -*.eledsec[1-9]R -*.eledsec[1-9][0-9] -*.eledsec[1-9][0-9]R -*.eledsec[1-9][0-9][0-9] -*.eledsec[1-9][0-9][0-9]R - -# glossaries -*.acn -*.acr -*.glg -*.glo -*.gls -*.glsdefs - -# gnuplottex -*-gnuplottex-* - -# gregoriotex -*.gaux -*.gtex - -# hyperref -*.brf - -# knitr -*-concordance.tex -# TODO Comment the next line if you want to keep your tikz graphics files -*.tikz -*-tikzDictionary - -# listings -*.lol - -# makeidx -*.idx -*.ilg -*.ind -*.ist - -# minitoc -*.maf -*.mlf -*.mlt -*.mtc[0-9]* -*.slf[0-9]* -*.slt[0-9]* -*.stc[0-9]* - -# minted -_minted* -*.pyg - -# morewrites -*.mw - -# nomencl -*.nlo - -# pax -*.pax - -# pdfpcnotes -*.pdfpc - -# sagetex -*.sagetex.sage -*.sagetex.py -*.sagetex.scmd - -# scrwfile -*.wrt - -# sympy -*.sout -*.sympy -sympy-plots-for-*.tex/ - -# pdfcomment -*.upa -*.upb - -# pythontex -*.pytxcode -pythontex-files-*/ - -# thmtools -*.loe - -# TikZ & PGF -*.dpth -*.md5 -*.auxlock - -# todonotes -*.tdo - -# easy-todo -*.lod - -# xindy -*.xdy - -# xypic precompiled matrices -*.xyc - -# endfloat -*.ttt -*.fff - -# Latexian -TSWLatexianTemp* - -## Editors: -# WinEdt -*.bak -*.sav - -# Texpad -.texpadtmp - -# Kile -*.backup - -# KBibTeX -*~[0-9]* - -# auto folder when using emacs and auctex -/auto/* - -# expex forward references with \gathertags -*-tags.tex - -### LaTeX Patch ### -# glossaries -*.glstex - - -# Text file backups (e.g. gedit, joe) -*~ -\#*\# -.\#* - -# Archive files -*.tgz -*.tar - -# Logs -*.log - -# Patch files -*.patch -*.diff -*.orig -*.rej - -# Cache and temporary files -*.pyc -.DS_Store -*.swp - -# ctags/etags files -/TAGS -/tags - -# Coverage output -coverage.info -coverage.info.raw -coverage/ -lcov-out/ - -/fuzzer_corpus - -# Profiler outputs -cachegrind.* -callgrind.* - -# Ignore stuff in the top level dir that shouldn't be checked in -/*.c -/*.cpp -/*.h -/*.py -/*.key -/*.pem -/*.der -/*.ber -/*.gpg -/*.pub -/*.crt \ No newline at end of file diff --git a/libs/parallel-containers/LICENSE_1_0.txt b/libs/parallel-containers/LICENSE_1_0.txt deleted file mode 100644 index 17560bd5e2..0000000000 --- a/libs/parallel-containers/LICENSE_1_0.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Mikhail Komarov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/libs/parallel-containers/cmake/CheckAVX.cmake b/libs/parallel-containers/cmake/CheckAVX.cmake deleted file mode 100644 index 183cb71ef4..0000000000 --- a/libs/parallel-containers/cmake/CheckAVX.cmake +++ /dev/null @@ -1,63 +0,0 @@ -include(CheckCSourceCompiles) -include(CheckCXXSourceCompiles) - -set(AVX_CODE " - #include - - int main() - { - __m256 a; - a = _mm256_set1_ps(0); - return 0; - } -") - -set(AVX2_CODE " - #include - - int main() - { - __m256i a = {0}; - a = _mm256_abs_epi16(a); - __m256i x; - _mm256_extract_epi64(x, 0); // we rely on this in our AVX2 code - return 0; - } -") - -macro(check_avx_lang lang type flags) - set(__FLAG_I 1) - set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) - foreach(__FLAG ${flags}) - if(NOT ${lang}_${type}_FOUND) - set(CMAKE_REQUIRED_FLAGS ${__FLAG}) - if(lang STREQUAL "CXX") - check_cxx_source_compiles("${${type}_CODE}" ${lang}_HAS_${type}_${__FLAG_I}) - else() - check_c_source_compiles("${${type}_CODE}" ${lang}_HAS_${type}_${__FLAG_I}) - endif() - if(${lang}_HAS_${type}_${__FLAG_I}) - set(${lang}_${type}_FOUND TRUE CACHE BOOL "${lang} ${type} support") - set(${lang}_${type}_FLAGS "${__FLAG}" CACHE STRING "${lang} ${type} flags") - endif() - math(EXPR __FLAG_I "${__FLAG_I}+1") - endif() - endforeach() - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) - - if(NOT ${lang}_${type}_FOUND) - set(${lang}_${type}_FOUND FALSE CACHE BOOL "${lang} ${type} support") - set(${lang}_${type}_FLAGS "" CACHE STRING "${lang} ${type} flags") - endif() - - mark_as_advanced(${lang}_${type}_FOUND ${lang}_${type}_FLAGS) - -endmacro() - -macro(check_avx) - check_avx_lang(C "AVX" " ;-mavx;/arch:AVX") - check_avx_lang(C "AVX2" " ;-mavx2 -mfma;/arch:AVX2") - - check_avx_lang(CXX "AVX" " ;-mavx;/arch:AVX") - check_avx_lang(CXX "AVX2" " ;-mavx2 -mfma;/arch:AVX2") -endmacro() \ No newline at end of file diff --git a/libs/parallel-containers/cmake/CheckSSE.cmake b/libs/parallel-containers/cmake/CheckSSE.cmake deleted file mode 100644 index 67e3ab5596..0000000000 --- a/libs/parallel-containers/cmake/CheckSSE.cmake +++ /dev/null @@ -1,138 +0,0 @@ -# Check if SSE instructions are available on the machine where -# the project is compiled. - -macro(check_sse) - if(CMAKE_SYSTEM_NAME MATCHES "Linux") - exec_program(cat ARGS "/proc/cpuinfo" OUTPUT_VARIABLE CPUINFO) - - string(REGEX REPLACE "^.*(sse2).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "sse2" "${SSE_THERE}" SSE2_TRUE) - if(SSE2_TRUE) - set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") - else(SSE2_TRUE) - set(SSE2_FOUND false CACHE BOOL "SSE2 available on host") - endif(SSE2_TRUE) - - # /proc/cpuinfo apparently omits sse3 :( - string(REGEX REPLACE "^.*[^s](sse3).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "sse3" "${SSE_THERE}" SSE3_TRUE) - if(NOT SSE3_TRUE) - string(REGEX REPLACE "^.*(T2300).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "T2300" "${SSE_THERE}" SSE3_TRUE) - endif(NOT SSE3_TRUE) - - string(REGEX REPLACE "^.*(ssse3).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "ssse3" "${SSE_THERE}" SSSE3_TRUE) - if(SSE3_TRUE OR SSSE3_TRUE) - set(SSE3_FOUND true CACHE BOOL "SSE3 available on host") - else(SSE3_TRUE OR SSSE3_TRUE) - set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") - endif(SSE3_TRUE OR SSSE3_TRUE) - if(SSSE3_TRUE) - set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host") - else(SSSE3_TRUE) - set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") - endif(SSSE3_TRUE) - - string(REGEX REPLACE "^.*(sse4_1).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "sse4_1" "${SSE_THERE}" SSE41_TRUE) - if(SSE41_TRUE) - set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host") - else(SSE41_TRUE) - set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") - endif(SSE41_TRUE) - - string(REGEX REPLACE "^.*(sse4_2).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "sse4_2" "${SSE_THERE}" SSE42_TRUE) - if(SSE42_TRUE) - set(SSE4_2_FOUND true CACHE BOOL "SSE4.2 available on host") - else(SSE42_TRUE) - set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host") - endif(SSE42_TRUE) - - elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") - exec_program("/usr/sbin/sysctl -n machdep.cpu.features" OUTPUT_VARIABLE - CPUINFO) - - string(REGEX REPLACE "^.*[^S](SSE2).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "SSE2" "${SSE_THERE}" SSE2_TRUE) - if(SSE2_TRUE) - set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") - else(SSE2_TRUE) - set(SSE2_FOUND false CACHE BOOL "SSE2 available on host") - endif(SSE2_TRUE) - - string(REGEX REPLACE "^.*[^S](SSE3).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "SSE3" "${SSE_THERE}" SSE3_TRUE) - if(SSE3_TRUE) - set(SSE3_FOUND true CACHE BOOL "SSE3 available on host") - else(SSE3_TRUE) - set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") - endif(SSE3_TRUE) - - string(REGEX REPLACE "^.*(SSSE3).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "SSSE3" "${SSE_THERE}" SSSE3_TRUE) - if(SSSE3_TRUE) - set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host") - else(SSSE3_TRUE) - set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") - endif(SSSE3_TRUE) - - string(REGEX REPLACE "^.*(SSE4.1).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "SSE4.1" "${SSE_THERE}" SSE41_TRUE) - if(SSE41_TRUE) - set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host") - else(SSE41_TRUE) - set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") - endif(SSE41_TRUE) - - string(REGEX REPLACE "^.*(SSE4.2).*$" "\\1" SSE_THERE ${CPUINFO}) - string(COMPARE EQUAL "SSE4.2" "${SSE_THERE}" SSE42_TRUE) - if(SSE42_TRUE) - set(SSE4_2_FOUND true CACHE BOOL "SSE4.2 available on host") - else(SSE42_TRUE) - set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host") - endif(SSE42_TRUE) - - elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") - # TODO - set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") - set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") - set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") - set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") - set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host") - else(CMAKE_SYSTEM_NAME MATCHES "Linux") - set(SSE2_FOUND true CACHE BOOL "SSE2 available on host") - set(SSE3_FOUND false CACHE BOOL "SSE3 available on host") - set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host") - set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host") - set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host") - endif(CMAKE_SYSTEM_NAME MATCHES "Linux") - - if(CMAKE_COMPILER_IS_GNUCXX) - execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) - if(GCC_VERSION VERSION_LESS 4.2) - set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host" FORCE) - set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host" FORCE) - endif() - endif(CMAKE_COMPILER_IS_GNUCXX) - - if(NOT SSE2_FOUND) - message(STATUS "Could not find support for SSE2 on this machine.") - endif(NOT SSE2_FOUND) - if(NOT SSE3_FOUND) - message(STATUS "Could not find support for SSE3 on this machine.") - endif(NOT SSE3_FOUND) - if(NOT SSSE3_FOUND) - message(STATUS "Could not find support for SSSE3 on this machine.") - endif(NOT SSSE3_FOUND) - if(NOT SSE4_1_FOUND) - message(STATUS "Could not find support for SSE4.1 on this machine.") - endif(NOT SSE4_1_FOUND) - if(NOT SSE4_2_FOUND) - message(STATUS "Could not find support for SSE4.2 on this machine.") - endif(NOT SSE4_2_FOUND) - - mark_as_advanced(SSE2_FOUND SSE3_FOUND SSSE3_FOUND SSE4_1_FOUND SSE4_2_FOUND) - -endmacro(check_sse) \ No newline at end of file diff --git a/libs/parallel-containers/cmake/PlatformConfiguration.cmake b/libs/parallel-containers/cmake/PlatformConfiguration.cmake deleted file mode 100644 index 403f015b9a..0000000000 --- a/libs/parallel-containers/cmake/PlatformConfiguration.cmake +++ /dev/null @@ -1,141 +0,0 @@ -include(CheckTypeSize) - -function(define_target_architecture prefix_name target_architecture) - string(TOUPPER ${target_architecture} UPPER_TARGET_ARCHITECTURE) - string(TOUPPER ${prefix_name} UPPER_PREFIX_NAME) - - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_ARCHITECTURE_IS_${UPPER_TARGET_ARCHITECTURE}) -endfunction() - -function(define_target_endianness prefix_name target_architecture) - string(TOUPPER ${target_architecture} UPPER_TARGET_ARCHITECTURE) - string(TOUPPER ${prefix_name} UPPER_PREFIX_NAME) - - if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64") - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_X86_FAMILY) - elseif(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV8" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV7S" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV6" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV5" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM32" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV7") - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_ARM_FAMILY) - elseif(${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64") - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_PPC_FAMILY) - endif() - - if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ALPHA" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV8" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV7S" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV6" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV5" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM32" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARMV7" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64") - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_LITTLE_ENDIAN) - elseif(${UPPER_TARGET_ARCHITECTURE} STREQUAL "M68K" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390X" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC32" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64") - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_IS_BIG_ENDIAN) - endif() -endfunction() - -function(define_target_platform_size prefix_name target_architecture) - string(TOUPPER ${target_architecture} UPPER_TARGET_ARCHITECTURE) - string(TOUPPER ${prefix_name} UPPER_PREFIX_NAME) - - if(${CMAKE_TARGET_ARCHITECTURE} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR}) - # check_type_size(int CMAKE_TARGET_INTEGER_SIZE_BYTE) - # math(EXPR CMAKE_TARGET_INTEGER_SIZE_BITS "${CMAKE_TARGET_INTEGER_SIZE_BYTE} * 8") - # add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=${CMAKE_TARGET_INTEGER_SIZE_BITS}) - - if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ALPHA" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390X") - add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=64) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_HAS_NATIVE_64BIT) - else() - add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=32) - endif() - else() - if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ALPHA" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64" OR - ${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390X") - add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=64) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_HAS_NATIVE_64BIT) - else() - add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=32) - endif() - endif() - - if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64") - add_definitions(-D${UPPER_PREFIX_NAME}_MP_USE_X86_64_ASM) - elseif(${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86") - add_definitions(-D${UPPER_PREFIX_NAME}_MP_USE_X86_32_ASM) - endif() -endfunction() - -function(define_target_platform_features prefix_name) - include(CheckSymbolExists) - - string(TOUPPER ${prefix_name} UPPER_PREFIX_NAME) - - if(UNIX) - if(APPLE) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_IS_DARWIN) - - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_ARC4RANDOM) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_MEMSET_S) - else() - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_CLOCK_GETTIME) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_POSIX_MLOCK) - endif() - - check_symbol_exists(clock_gettime sys/time.h HAVE_CLOCK_GETTIME) - check_symbol_exists(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) - - if(HAVE_GETTIMEOFDAY) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_GETTIMEOFDAY) - endif() - - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_TYPE_IS_UNIX) - - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_GMTIME_R) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_DEV_RANDOM) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_POSIX1) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_FILELSYSTEM) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_TIMEGM) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_SOCKETS) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_READDIR) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_DLOPEN) - elseif(WIN32) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_TYPE_IS_WINDOWS) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_WIN32) - - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_RTLGENRANDOM) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_GMTIME_S) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_LOADLIBRARY) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_MKGMTIME) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_QUERY_PREF_COUNTER) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_VIRTUAL_LOCK) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_RTLSECUREZEROMEMORY) - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_STL_FILESYSTEM_MSVC) - endif() - - add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_OS_HAS_THREADS) -endfunction() \ No newline at end of file diff --git a/libs/parallel-containers/cmake/TargetArchitecture.cmake b/libs/parallel-containers/cmake/TargetArchitecture.cmake deleted file mode 100644 index afaaa7274f..0000000000 --- a/libs/parallel-containers/cmake/TargetArchitecture.cmake +++ /dev/null @@ -1,163 +0,0 @@ - -# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h -# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) - -# Regarding POWER/PowerPC, just as is noted in the Qt source, -# "There are many more known variants/revisions that we do not handle/detect." - -set(archdetect_c_code " -#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) - #if defined(__ARM64_ARCH_8__) - #error cmake_ARCH armv8 - #elif defined(__aarch64__) - #error cmake_ARCH arm64 - #elif defined(__ARM_ARCH_7__) \\ - || defined(__ARM_ARCH_7A__) \\ - || defined(__ARM_ARCH_7R__) \\ - || defined(__ARM_ARCH_7M__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) - #error cmake_ARCH armv7 - #elif defined(__ARM_ARCH_7S__) - #error cmake_ARCH armv7s - #elif defined(__ARM_ARCH_6__) \\ - || defined(__ARM_ARCH_6J__) \\ - || defined(__ARM_ARCH_6T2__) \\ - || defined(__ARM_ARCH_6Z__) \\ - || defined(__ARM_ARCH_6K__) \\ - || defined(__ARM_ARCH_6ZK__) \\ - || defined(__ARM_ARCH_6M__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) - #error cmake_ARCH armv6 - #elif defined(__ARM_ARCH_5TEJ__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) - #error cmake_ARCH armv5 - #else - #error cmake_ARCH arm32 - #endif -#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) - #error cmake_ARCH i386 -#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) - #error cmake_ARCH x86_64 -#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) - #error cmake_ARCH ia64 -#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ - || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ - || defined(_M_MPPC) || defined(_M_PPC) - #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) - #error cmake_ARCH ppc64 - #else - #error cmake_ARCH ppc - #endif -#elif defined(__mips__) || defined(__mips) - #if defined(__LP64__) || defined(_LP64) - #error cmake_ARCH mips64 - #else - #error cmake_ARCH mips32 - #endif -#elif defined(__sparc__) - #if defined(__LP64__) || defined(_LP64) - #error cmake_ARCH sparc64 - #else - #error cmake_ARCH sparc32 - #endif -#elif defined(__alpha__) - #error cmake_ARCH alpha -#elif defined(__hppa__) || defined(__hppa) - #error cmake_ARCH hppa -#elif defined(__m68k__) - #error cmake_ARCH m68k -#elif defined(__sh__) - #error cmake_ARCH sh -#elif defined(__s390x__) - #error cmake_ARCH s390x -#elif defined(__s390__) - #error cmake_ARCH s390 -#endif - -#error cmake_ARCH unknown -") - -# Set ppc_support to TRUE before including this file or ppc and ppc64 -# will be treated as invalid architectures since they are no longer supported by Apple - -function(target_architecture OUTPUT_ARCHITECTURE) - if(APPLE AND CMAKE_OSX_ARCHITECTURES) - # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set - # First let's normalize the order of the values - - # Note that it's not possible to compile PowerPC applications if you are using - # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we - # disable it by default - # See this page for more information: - # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 - - # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. - # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. - - foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) - if("${osx_arch}" STREQUAL "ppc" AND ppc_support) - set(osx_arch_ppc TRUE) - elseif("${osx_arch}" STREQUAL "i386") - set(osx_arch_i386 TRUE) - elseif("${osx_arch}" STREQUAL "x86_64") - set(osx_arch_x86_64 TRUE) - elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) - set(osx_arch_ppc64 TRUE) - else() - message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") - endif() - endforeach() - - # Now add all the architectures in our normalized order - if(osx_arch_ppc) - list(APPEND ARCH ppc) - endif() - - if(osx_arch_i386) - list(APPEND ARCH i386) - endif() - - if(osx_arch_x86_64) - list(APPEND ARCH x86_64) - endif() - - if(osx_arch_ppc64) - list(APPEND ARCH ppc64) - endif() - else() - file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") - - enable_language(C) - - # Detect the architecture in a rather creative way... - # This compiles a small C program which is a series of ifdefs that selects a - # particular #error preprocessor directive whose message string contains the - # target architecture. The program will always fail to compile (both because - # file is not a valid C program, and obviously because of the presence of the - # #error preprocessor directives... but by exploiting the preprocessor in this - # way, we can detect the correct target architecture even when cross-compiling, - # since the program itself never needs to be run (only the compiler/preprocessor) - try_run(run_result_unused - compile_result_unused - "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}/arch.c" - COMPILE_OUTPUT_VARIABLE RESULT_ARCH - CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} - ) - - # Parse the architecture name from the compiler output - string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${RESULT_ARCH}") - - # Get rid of the value marker leaving just the architecture name - string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") - - # If we are compiling with an unknown architecture this variable should - # already be set to "unknown" but in the case that it's empty (i.e. due - # to a typo in the code), then set it to unknown - if(NOT ARCH) - set(ARCH unknown) - endif() - endif() - - set(${OUTPUT_ARCHITECTURE} "${ARCH}" PARENT_SCOPE) -endfunction() diff --git a/libs/parallel-containers/cmake/TargetConfiguration.cmake b/libs/parallel-containers/cmake/TargetConfiguration.cmake deleted file mode 100644 index f72ff9bbb2..0000000000 --- a/libs/parallel-containers/cmake/TargetConfiguration.cmake +++ /dev/null @@ -1,6 +0,0 @@ -macro(define_current_target target_name project_name) - set(CMAKE_CURRENT_TARGET ${target_name}) - string(TOUPPER ${target_name} CMAKE_UPPER_CURRENT_TARGET) - string(TOUPPER ${project_name} CMAKE_UPPER_PROJECT_NAME) - add_definitions(-D${CMAKE_UPPER_PROJECT_NAME}_HAS_${CMAKE_UPPER_CURRENT_TARGET}) -endmacro() \ No newline at end of file diff --git a/libs/parallel-containers/cmake/architectures/alpha.json b/libs/parallel-containers/cmake/architectures/alpha.json deleted file mode 100644 index 72c50e871d..0000000000 --- a/libs/parallel-containers/cmake/architectures/alpha.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "endian": "little", - "word_size": 64, - "aliases": [ - "axp", - "alphaaxp" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/arm32.json b/libs/parallel-containers/cmake/architectures/arm32.json deleted file mode 100644 index 9f7934c8cf..0000000000 --- a/libs/parallel-containers/cmake/architectures/arm32.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "endian": "little", - "family": "arm", - "aliases": [ - "arm", - "armeb", - "armel", - "armhf", - "evbarm", - "armv7", - "armv7l", - "armv7-a", - "armv8l" - ], - "isa_Extensions": "neon" -} diff --git a/libs/parallel-containers/cmake/architectures/arm64.json b/libs/parallel-containers/cmake/architectures/arm64.json deleted file mode 100644 index dfb28913cc..0000000000 --- a/libs/parallel-containers/cmake/architectures/arm64.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "endian": "little", - "word_size": 64, - "family": "arm", - "aliases": [ - "aarch64", - "armv8", - "armv8-a", - "arm64" - ], - "isa_extensions": [ - "neon", - "armv8crypto", - "armv8sm3", - "armv8sm4", - "armv8sha3", - "armv8sha512" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/hppa.json b/libs/parallel-containers/cmake/architectures/hppa.json deleted file mode 100644 index 87aedf039a..0000000000 --- a/libs/parallel-containers/cmake/architectures/hppa.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "word_size": 64, - "endian": "little", - "aliases": [ - "hp-pa", - "parisc", - "parisc64", - "pa-risc", - "hp-parisc", - "hp-pa-risc" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/ia64.json b/libs/parallel-containers/cmake/architectures/ia64.json deleted file mode 100644 index a71d2b51d4..0000000000 --- a/libs/parallel-containers/cmake/architectures/ia64.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "word_size": 64, - "aliases": [ - "itanium", - "itanic" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/llvm.json b/libs/parallel-containers/cmake/architectures/llvm.json deleted file mode 100644 index cb382a5fae..0000000000 --- a/libs/parallel-containers/cmake/architectures/llvm.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "word_size": 64, - "endian": "little" -} diff --git a/libs/parallel-containers/cmake/architectures/m68k.json b/libs/parallel-containers/cmake/architectures/m68k.json deleted file mode 100644 index d5d2b9c8d2..0000000000 --- a/libs/parallel-containers/cmake/architectures/m68k.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "word_size": 32, - "endian": "big", - "aliases": [ - "680x0", - "68k" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/mips32.json b/libs/parallel-containers/cmake/architectures/mips32.json deleted file mode 100644 index 1742654d4b..0000000000 --- a/libs/parallel-containers/cmake/architectures/mips32.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "word_size": 32, - "endian": "little", - "aliases": [ - "mips", - "mipsbe", - "mipsle", - "mipsel" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/mips64.json b/libs/parallel-containers/cmake/architectures/mips64.json deleted file mode 100644 index 4d5cbdb86d..0000000000 --- a/libs/parallel-containers/cmake/architectures/mips64.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "word_size": 64, - "endian": "little", - "aliases": [ - "mips64el" - ] -} \ No newline at end of file diff --git a/libs/parallel-containers/cmake/architectures/powerpcspe.json b/libs/parallel-containers/cmake/architectures/powerpcspe.json deleted file mode 100644 index 79ba6c9b54..0000000000 --- a/libs/parallel-containers/cmake/architectures/powerpcspe.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "word_size": 32, - "endian": "big", - "family": "ppc" -} diff --git a/libs/parallel-containers/cmake/architectures/ppc32.json b/libs/parallel-containers/cmake/architectures/ppc32.json deleted file mode 100644 index 96d76ef168..0000000000 --- a/libs/parallel-containers/cmake/architectures/ppc32.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "word_size": 32, - "endian": "big", - "family": "ppc", - "aliases": [ - "powerpc", - "ppc" - ], - "isa_extensions": [ - "altivec" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/ppc64.json b/libs/parallel-containers/cmake/architectures/ppc64.json deleted file mode 100644 index a617f52fd8..0000000000 --- a/libs/parallel-containers/cmake/architectures/ppc64.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "endian": "big", - "word_size": 64, - "family": "ppc", - "aliases": [ - "powerpc64", - "powerpc64le", - "ppc64le", - "ppc64el" - ], - "isa_extensions": [ - "altivec", - "ppccrypto" - ] -} \ No newline at end of file diff --git a/libs/parallel-containers/cmake/architectures/riscv64.json b/libs/parallel-containers/cmake/architectures/riscv64.json deleted file mode 100644 index f64ec22e32..0000000000 --- a/libs/parallel-containers/cmake/architectures/riscv64.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "endian": "little", - "word_size": 32, - "family": "riscv" -} \ No newline at end of file diff --git a/libs/parallel-containers/cmake/architectures/s390.json b/libs/parallel-containers/cmake/architectures/s390.json deleted file mode 100644 index 690902f193..0000000000 --- a/libs/parallel-containers/cmake/architectures/s390.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "word_size": 32, - "endian": "big" -} \ No newline at end of file diff --git a/libs/parallel-containers/cmake/architectures/s390x.json b/libs/parallel-containers/cmake/architectures/s390x.json deleted file mode 100644 index b5e5afbe66..0000000000 --- a/libs/parallel-containers/cmake/architectures/s390x.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "endian": "big", - "word_size": 64 -} \ No newline at end of file diff --git a/libs/parallel-containers/cmake/architectures/sparc32.json b/libs/parallel-containers/cmake/architectures/sparc32.json deleted file mode 100644 index 0e74eb2bcd..0000000000 --- a/libs/parallel-containers/cmake/architectures/sparc32.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "endian": "big", - "word_size": 32, - "family": "sparc", - "aliases": [ - "sparc" - ] -} \ No newline at end of file diff --git a/libs/parallel-containers/cmake/architectures/sparc64.json b/libs/parallel-containers/cmake/architectures/sparc64.json deleted file mode 100644 index 7c8bd96162..0000000000 --- a/libs/parallel-containers/cmake/architectures/sparc64.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "endian": "big", - "word_size": 64, - "family": "sparc" -} \ No newline at end of file diff --git a/libs/parallel-containers/cmake/architectures/superh.json b/libs/parallel-containers/cmake/architectures/superh.json deleted file mode 100644 index 1cf2aad84a..0000000000 --- a/libs/parallel-containers/cmake/architectures/superh.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "endian": "little", - "word_size": 32, - "aliases": [ - "sh4" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/x32.json b/libs/parallel-containers/cmake/architectures/x32.json deleted file mode 100644 index 8191cd0c4a..0000000000 --- a/libs/parallel-containers/cmake/architectures/x32.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "endian": "little", - "word_size": 32, - "family": "x86", - "isa_extensions": [ - "aesni", - "avx2", - "bmi2", - "rdrand", - "rdseed", - "sha", - "sse2", - "sse41", - "sse42", - "ssse3" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/x86_32.json b/libs/parallel-containers/cmake/architectures/x86_32.json deleted file mode 100644 index c41102b432..0000000000 --- a/libs/parallel-containers/cmake/architectures/x86_32.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "endian": "little", - "word_size": 32, - "family": "x86", - "aliases": [ - "ia32", - "x86", - "ix86", - "80x86", - "i86pc", - "x86pc", - "bepc", - "i686-at386", - "i686", - "i586", - "i386" - ], - "isa_extensions": [ - "aesni", - "avx2", - "bmi2", - "rdrand", - "rdseed", - "sha", - "sse2", - "sse41", - "sse42", - "ssse3" - ] -} diff --git a/libs/parallel-containers/cmake/architectures/x86_64.json b/libs/parallel-containers/cmake/architectures/x86_64.json deleted file mode 100644 index f5608179c2..0000000000 --- a/libs/parallel-containers/cmake/architectures/x86_64.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "endian": "little", - "word_size": 64, - "family": "x86", - "aliases": [ - "amd64", - "x86-64", - "em64t", - "x64", - "x86_amd64" - ], - "isa_extensions": [ - "aesni", - "avx2", - "bmi2", - "rdrand", - "rdseed", - "sha", - "sse2", - "sse41", - "sse42", - "ssse3" - ] -} \ No newline at end of file diff --git a/libs/parallel-containers/cmake/packages/FindCrypto3.cmake b/libs/parallel-containers/cmake/packages/FindCrypto3.cmake deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libs/parallel-containers/cmake/packages/FindValgrind.cmake b/libs/parallel-containers/cmake/packages/FindValgrind.cmake deleted file mode 100644 index 82730b172b..0000000000 --- a/libs/parallel-containers/cmake/packages/FindValgrind.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# Find Valgrind. -# -# This module defines: -# VALGRIND_INCLUDE_DIR, where to find valgrind/memcheck.h, etc. -# VALGRIND_PROGRAM, the valgrind executable. -# VALGRIND_FOUND, If false, do not try to use valgrind. -# -# If you have valgrind installed in a non-standard place, you can define -# VALGRIND_PREFIX to tell cmake_backup where it is. -# -# NOTE: Copied from the opencog project, where it is distributed under the -# terms of the New BSD License. - -find_path(VALGRIND_INCLUDE_DIR valgrind/memcheck.h - /usr/include /usr/local/include ${VALGRIND_PREFIX}/include) -find_program(VALGRIND_PROGRAM NAMES valgrind PATH - /usr/bin /usr/local/bin ${VALGRIND_PREFIX}/bin) - -find_package_handle_standard_args(VALGRIND DEFAULT_MSG - VALGRIND_INCLUDE_DIR - VALGRIND_PROGRAM) - -mark_as_advanced(VALGRIND_INCLUDE_DIR VALGRIND_PROGRAM) \ No newline at end of file