From aff78e2555c0a75cdf8cb5fec12ecb22beb62060 Mon Sep 17 00:00:00 2001 From: Joerg-Christian Boehme Date: Thu, 4 Oct 2018 17:19:12 +0200 Subject: [PATCH] Add 'botan' package --- cmake/configs/default.cmake | 1 + cmake/projects/botan/hunter.cmake | 71 ++++ .../botan/schemes/url_sha1_botan.cmake.in | 299 ++++++++++++++++ .../botan/schemes/url_sha1_botan_ios.cmake.in | 324 ++++++++++++++++++ .../schemes/url_sha1_botan_macos.cmake.in | 268 +++++++++++++++ .../botan/schemes/url_sha1_botan_win.cmake.in | 290 ++++++++++++++++ docs/packages/pkg/botan.rst | 20 ++ examples/botan/CMakeLists.txt | 18 + examples/botan/boo.cpp | 26 ++ 9 files changed, 1317 insertions(+) create mode 100644 cmake/projects/botan/hunter.cmake create mode 100644 cmake/projects/botan/schemes/url_sha1_botan.cmake.in create mode 100644 cmake/projects/botan/schemes/url_sha1_botan_ios.cmake.in create mode 100644 cmake/projects/botan/schemes/url_sha1_botan_macos.cmake.in create mode 100644 cmake/projects/botan/schemes/url_sha1_botan_win.cmake.in create mode 100644 docs/packages/pkg/botan.rst create mode 100644 examples/botan/CMakeLists.txt create mode 100644 examples/botan/boo.cpp diff --git a/cmake/configs/default.cmake b/cmake/configs/default.cmake index 06c395e929..0d8db322a9 100644 --- a/cmake/configs/default.cmake +++ b/cmake/configs/default.cmake @@ -182,6 +182,7 @@ hunter_default_version(bento4 VERSION 1.5.1-628-e6ee435-p0) hunter_default_version(binaryen VERSION 1.38.28-p1) hunter_default_version(bison VERSION 3.0.4-p0) hunter_default_version(boost-pba VERSION 1.0.0-p0) +hunter_default_version(botan VERSION 2.11.0-110af9494) hunter_default_version(breakpad VERSION 0.0.0-12ecff3-p2) hunter_default_version(bullet VERSION 2.87-p0) hunter_default_version(c-ares VERSION 1.14.0-p0) diff --git a/cmake/projects/botan/hunter.cmake b/cmake/projects/botan/hunter.cmake new file mode 100644 index 0000000000..18669c23f9 --- /dev/null +++ b/cmake/projects/botan/hunter.cmake @@ -0,0 +1,71 @@ +# !!! DO NOT PLACE HEADER GUARDS HERE !!! + +include(hunter_add_version) +include(hunter_cacheable) +include(hunter_download) +include(hunter_pick_scheme) +include(hunter_cmake_args) +include(hunter_configuration_types) + +hunter_add_version( + PACKAGE_NAME + botan + VERSION + 2.11.0-110af9494 + URL + "https://github.com/randombit/botan/archive/110af949412e7c4b28b447a3600a947ddf2a2f2f.zip" + SHA1 + b97b5a934c872310992635a2ef5d016e1e59a2dd +) + +hunter_add_version( + PACKAGE_NAME + botan + VERSION + 2.11.0 + URL + "https://github.com/randombit/botan/archive/2.11.0.tar.gz" + SHA1 + f9667a53c19a7eb8999f3580baf21dc29c6a5f33 +) + +hunter_add_version( + PACKAGE_NAME + botan + VERSION + 2.10.0 + URL + "https://github.com/randombit/botan/archive/2.10.0.tar.gz" + SHA1 + 6e6b0e4a4b5a69ff42de2dfec2cd998a981abd2d +) + +hunter_cmake_args( + botan + CMAKE_ARGS + WITH_BZIP2=NO + WITH_ZLIB=NO + PKGCONFIG_EXPORT_TARGETS=botan-2 +) + +hunter_configuration_types(botan CONFIGURATION_TYPES Release) + +if(MINGW) + hunter_pick_scheme(DEFAULT url_sha1_botan) +elseif(WIN32) + hunter_pick_scheme(DEFAULT url_sha1_botan_win) +elseif(APPLE) + if(IOS) + hunter_pick_scheme(DEFAULT url_sha1_botan_ios) + else() + hunter_pick_scheme(DEFAULT url_sha1_botan_macos) + endif() +else() + hunter_pick_scheme(DEFAULT url_sha1_botan) +endif() + +hunter_cacheable(botan) +hunter_download(PACKAGE_NAME botan + PACKAGE_UNRELOCATABLE_TEXT_FILES + lib/pkgconfig/botan-2.pc +) diff --git a/cmake/projects/botan/schemes/url_sha1_botan.cmake.in b/cmake/projects/botan/schemes/url_sha1_botan.cmake.in new file mode 100644 index 0000000000..61f4e73f7f --- /dev/null +++ b/cmake/projects/botan/schemes/url_sha1_botan.cmake.in @@ -0,0 +1,299 @@ +cmake_minimum_required(VERSION 3.0) + +project(Hunter) + +include("@HUNTER_SELF@/cmake/Hunter") + +include(ExternalProject) # ExternalProject_Add + +# some Hunter modules will be used +list(APPEND CMAKE_MODULE_PATH "@HUNTER_SELF@/cmake/modules") + +include(hunter_status_debug) +include(hunter_assert_not_empty_string) +include(hunter_get_toolchain_binaries) +include(hunter_get_build_flags) + +# print this message if HUNTER_STATUS_DEBUG option is ON +hunter_status_debug("Scheme: url_sha1_botan") + +# Check variables is not empty +hunter_assert_not_empty_string("@HUNTER_SELF@") +hunter_assert_not_empty_string("@HUNTER_EP_NAME@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_URL@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SHA1@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_DOWNLOAD_DIR@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SOURCE_DIR@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_INSTALL_PREFIX@") +hunter_assert_not_empty_string("@HUNTER_INSTALL_PREFIX@") +hunter_assert_not_empty_string("@HUNTER_TLS_VERIFY@") + +# Build command and options + +hunter_get_toolchain_binaries( + OUT_AR + ar + OUT_AS + as + OUT_LD + ld + OUT_NM + nm + OUT_OBJCOPY + objcopy + OUT_OBJDUMP + objdump + OUT_RANLIB + ranlib + OUT_STRIP + strip + OUT_CPP + cpp + OUT_CC + cc + OUT_CXX + cxx +) + +hunter_get_build_flags( + INSTALL_DIR + "@HUNTER_PACKAGE_INSTALL_PREFIX@" + PACKAGE_CONFIGURATION_TYPES + "@HUNTER_PACKAGE_CONFIGURATION_TYPES@" + OUT_CPPFLAGS + cppflags + OUT_CFLAGS + cflags + OUT_CXXFLAGS + cxxflags + OUT_LDFLAGS + ldflags +) + +# Usage: configure.py [options] +# +# Options: +# --version show program's version number and exit +# -h, --help show this help message and exit +# --verbose Show debug messages +# --quiet Show only warnings and errors +# +# Target options: +# --cpu=CPU set the target CPU architecture +# --os=OS set the target operating system +# --cc=COMPILER set the desired build compiler +# --cc-min-version=MAJOR.MINOR Set the minimal version of the target +# compiler. Use --cc-min-version=0.0 to +# support all compiler versions. Default is +# auto detection. +# --cc-bin=BINARY set path to compiler binary +# --cc-abi-flags=FLAGS set compiler ABI flags +# --cxxflags=FLAGS override all compiler flags +# --extra-cxxflags=FLAGS set extra compiler flags +# --ldflags=FLAGS set linker flags +# --ar-command=AR set path to static archive creator +# --ar-options=AR_OPTIONS set options for ar +# --msvc-runtime=RT specify MSVC runtime (MT, MD, MTd, MDd) +# --with-endian=ORDER override byte order guess +# --with-os-features=FEAT specify OS features to use +# --without-os-features=FEAT specify OS features to disable +# --disable-sse2 disable SSE2 intrinsics +# --disable-ssse3 disable SSSE3 intrinsics +# --disable-sse4.1 disable SSE4.1 intrinsics +# --disable-sse4.2 disable SSE4.2 intrinsics +# --disable-avx2 disable AVX2 intrinsics +# --disable-bmi2 disable BMI2 intrinsics +# --disable-rdrand disable RDRAND intrinsics +# --disable-rdseed disable RDSEED intrinsics +# --disable-aes-ni disable AES-NI intrinsics +# --disable-sha-ni disable SHA-NI intrinsics +# --disable-altivec disable AltiVec intrinsics +# --disable-neon disable NEON intrinsics +# --disable-armv8crypto disable ARMv8Crypto intrinsics +# +# Build options: +# --with-debug-info include debug symbols +# --with-sanitizers enable ASan/UBSan checks +# --enable-sanitizers=SAN enable specific sanitizers +# --without-stack-protector disable stack smashing protections +# --with-coverage add coverage info and disable opts +# --with-coverage-info add coverage info +# --disable-shared-library disable building shared library +# --disable-static-library disable building static library +# --optimize-for-size optimize for code size +# --no-optimizations disable all optimizations (for debugging) +# --debug-mode enable debug info, disable optimizations +# --amalgamation use amalgamation to build +# --single-amalgamation-file build single file instead of splitting on +# ABI +# --with-build-dir=DIR setup the build in DIR +# --with-external-includedir=DIR use DIR for external includes +# --with-external-libdir=DIR use DIR for external libs +# --with-sysroot-dir=DIR use DIR for system root while cross- +# compiling +# --with-openmp enable use of OpenMP +# --link-method=METHOD choose how links to include headers are +# created (symlink, hardlink, copy) +# --with-local-config=FILE include the contents of FILE into build.h +# --distribution-info=STRING distribution specific version +# --maintainer-mode Enable extra warnings +# --with-python-versions=N.M where to install botan2.py (def 2.7) +# --with-valgrind use valgrind API +# --unsafe-fuzzer-mode Disable essential checks for testing +# --build-fuzzers=TYPE Build fuzzers (afl, libfuzzer, klee, test) +# --with-fuzzer-lib=LIB additionally link in LIB +# +# Documentation Options: +# --without-documentation Skip building/installing documentation +# --with-sphinx Use Sphinx +# --with-pdf Use Sphinx to generate PDF doc +# --with-rst2man Use rst2man to generate man page +# --with-doxygen Use Doxygen +# +# Module selection: +# --module-policy=POL module policy file (see src/build- +# data/policy) +# --enable-modules=MODS enable specific modules +# --disable-modules=MODS disable specific modules +# --minimized-build minimize build +# --with-bearssl use bearssl +# --with-boost use boost +# --with-bzip2 use bzip2 +# --with-lzma use lzma +# --with-openssl use openssl +# --with-commoncrypto use commoncrypto +# --with-sqlite3 use sqlite3 +# --with-zlib use zlib +# --with-tpm use tpm +# +# Installation options: +# --program-suffix=SUFFIX append string to program names +# --library-suffix=SUFFIX append string to library names +# --prefix=DIR set the install prefix +# --docdir=DIR set the doc install dir +# --bindir=DIR set the binary install dir +# --libdir=DIR set the library install dir +# --mandir=DIR set the install dir for man pages +# --includedir=DIR set the include file install dir +# +# Informational: +# --list-modules list available modules and exit +# --list-os-features list available OS features and exit +# + +if(ANDROID) + list(APPEND configure_opts --os=android) + set(cpu_flag "${CMAKE_ANDROID_ARCH_ABI}") + if("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL "arm64-v8a") + set(cpu_flag "arm64") + elseif("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL "armeabi-v7a") + set(cpu_flag "armv7-a") + elseif("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL "armeabi") + set(cpu_flag "arm") + endif() + + list(APPEND configure_opts --cpu=${cpu_flag}) +elseif(UNIX) + list(APPEND configure_opts --os=linux) +endif() + +if("@HUNTER_PACKAGE_CONFIGURATION_TYPES@" STREQUAL "Debug") + list(APPEND configure_opts --debug-mode) +endif() + +if(HUNTER_STATUS_DEBUG) + list(APPEND configure_opts --verbose) +endif() + +if(BUILD_SHARED_LIBS) + list(APPEND configure_opt --disable-static-library) +else() + list(APPEND configure_opts --disable-shared-library) +endif() + +if(WITH_ZLIB) + list(APPEND configure_opts --with-zlib) + hunter_add_package(ZLIB) +endif() + +if(WITH_BZIP2) + list(APPEND configure_opts --with-bzip2) + hunter_add_package(BZip2) +endif() + +if(ENABLE_MODULES) + list(APPEND configure_opts --enable-modules=${ENABLE_MODULES}) +endif() + +list(APPEND configure_opts + --cc-bin=${cxx} + --extra-cxxflags=${cxxflags} + "--ldflags=${cxxflags} ${ldflags}" +) + +if(NOT "${ar}" STREQUAL "") + list(APPEND configure_opts --ar-command=${ar}) +endif() + +set(autotools_build_command "make") +if(MINGW) + set(autotools_build_command "nmake") +endif() + +if(NOT "@HUNTER_JOBS_OPTION@" STREQUAL "") + list(APPEND autotools_build_command "-j" "@HUNTER_JOBS_OPTION@") +endif() + +ExternalProject_Add( + @HUNTER_EP_NAME@ # Name of the external project. Actually not used set for beautify logging messages + URL + @HUNTER_PACKAGE_URL@ # URL of the package to download + URL_HASH + SHA1=@HUNTER_PACKAGE_SHA1@ # SHA1 hash + DOWNLOAD_DIR + "@HUNTER_PACKAGE_DOWNLOAD_DIR@" # Archive destination location + TLS_VERIFY + "@HUNTER_TLS_VERIFY@" + SOURCE_DIR + "@HUNTER_PACKAGE_SOURCE_DIR@" # Unpack directory + INSTALL_DIR + "@HUNTER_INSTALL_PREFIX@" # not used actually (see install command) + CONFIGURE_COMMAND + "./configure.py" + "--without-documentation" + "--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@" + "--with-external-includedir=@HUNTER_INSTALL_PREFIX@/include" + "--with-external-libdir=@HUNTER_INSTALL_PREFIX@/lib" + ${configure_opts} + BUILD_COMMAND + ${autotools_build_command} libs + BUILD_IN_SOURCE + 1 + INSTALL_COMMAND + make install + COMMAND # Copy license files + "@CMAKE_COMMAND@" + "-C@HUNTER_ARGS_FILE@" # for 'HUNTER_INSTALL_LICENSE_FILES' + "-Dsrcdir=@HUNTER_PACKAGE_SOURCE_DIR@" + "-Ddstdir=@HUNTER_PACKAGE_LICENSE_DIR@" + -P + "@HUNTER_SELF@/scripts/try-copy-license.cmake" +) + +string(COMPARE EQUAL "${DEPENDS_ON_PKGCONFIGS}" "" default_pkgconfig) +if(NOT default_pkgconfig) + set(DEPENDS_ON_PACKAGES ${DEPENDS_ON_PKGCONFIGS}) +endif() + +set(PKG_GENERATE_SHARED "${BUILD_SHARED_LIBS}") + +foreach(PKG_CONFIG_MODULE ${PKGCONFIG_EXPORT_TARGETS}) + # Use: + # * DEPENDS_ON_PACKAGES + # * PKG_GENERATE_SHARED + configure_file( + "@HUNTER_GLOBAL_SCRIPT_DIR@/pkgconfig-export-targets.cmake.in" + "@HUNTER_PACKAGE_INSTALL_PREFIX@/lib/cmake/${PKG_CONFIG_MODULE}/${PKG_CONFIG_MODULE}Config.cmake" + @ONLY + ) +endforeach() diff --git a/cmake/projects/botan/schemes/url_sha1_botan_ios.cmake.in b/cmake/projects/botan/schemes/url_sha1_botan_ios.cmake.in new file mode 100644 index 0000000000..0804390649 --- /dev/null +++ b/cmake/projects/botan/schemes/url_sha1_botan_ios.cmake.in @@ -0,0 +1,324 @@ +cmake_minimum_required(VERSION 3.0) + +project(Hunter) + +include("@HUNTER_SELF@/cmake/Hunter") + +include(ExternalProject) # ExternalProject_Add + +# some Hunter modules will be used +list(APPEND CMAKE_MODULE_PATH "@HUNTER_SELF@/cmake/modules") + +include(hunter_dump_cmake_flags) +include(hunter_status_debug) +include(hunter_assert_not_empty_string) +include(hunter_unsetvar) + +# print this message if HUNTER_STATUS_DEBUG option is ON +hunter_status_debug("Scheme: url_sha1_botan_ios") + +# Check variables is not empty +hunter_assert_not_empty_string("@HUNTER_SELF@") +hunter_assert_not_empty_string("@HUNTER_EP_NAME@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_URL@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SHA1@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_DOWNLOAD_DIR@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SOURCE_DIR@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_INSTALL_PREFIX@") +hunter_assert_not_empty_string("@HUNTER_INSTALL_PREFIX@") +hunter_assert_not_empty_string("@HUNTER_TLS_VERIFY@") + +# Note: support for single architecture/native iOS builds (i.e., arm64) +hunter_assert_not_empty_string("@IPHONEOS_ARCHS@@IPHONESIMULATOR_ARCHS@") +hunter_assert_not_empty_string("@IOS_SDK_VERSION@") +hunter_assert_not_empty_string("@IPHONESIMULATOR_ROOT@") +hunter_assert_not_empty_string("@IPHONEOS_ROOT@") + +hunter_dump_cmake_flags(SKIP_INCLUDES) +# -> CMAKE_CXX_FLAGS +# -> CMAKE_C_FLAGS + +set(configure_architectures @IPHONEOS_ARCHS@ @IPHONESIMULATOR_ARCHS@) + +list(FIND configure_architectures "armv7s" x) +if(${x} GREATER -1) + message(STATUS "armv7s not supported by botan.") + list(REMOVE_ITEM configure_architectures "armv7s") +endif() + +hunter_unsetvar(botan_input_libraries) + +foreach(arch ${configure_architectures}) + list( + APPEND + botan_input_libraries + "@HUNTER_PACKAGE_SOURCE_DIR@/${arch}/libbotan-2.a" + ) +endforeach() + +# fuse all libraries by 'lipo' +list(GET configure_architectures 0 first_architecture) +ExternalProject_Add( + "@HUNTER_EP_NAME@-ios_universal" + DOWNLOAD_COMMAND + "" + DOWNLOAD_DIR + "@HUNTER_PACKAGE_DOWNLOAD_DIR@" + TLS_VERIFY + "@HUNTER_TLS_VERIFY@" + SOURCE_DIR + "@HUNTER_PACKAGE_SOURCE_DIR@/ios_universal" + INSTALL_DIR + "@HUNTER_PACKAGE_INSTALL_PREFIX@" + # not used, just avoid creating Install/ empty directory + CONFIGURE_COMMAND + "" + BUILD_COMMAND + "" + INSTALL_COMMAND + lipo + -create + ${botan_input_libraries} + -o + "@HUNTER_PACKAGE_INSTALL_PREFIX@/lib/libbotan-2.a" + COMMAND # Copy license files + "@CMAKE_COMMAND@" + "-C@HUNTER_ARGS_FILE@" # for 'HUNTER_INSTALL_LICENSE_FILES' + "-Dsrcdir=@HUNTER_PACKAGE_SOURCE_DIR@/${first_architecture}" + "-Ddstdir=@HUNTER_PACKAGE_LICENSE_DIR@" + -P + "@HUNTER_SELF@/scripts/try-copy-license.cmake" +) + +# Usage: configure.py [options] +# +# Options: +# --version show program's version number and exit +# -h, --help show this help message and exit +# --verbose Show debug messages +# --quiet Show only warnings and errors +# +# Target options: +# --cpu=CPU set the target CPU architecture +# --os=OS set the target operating system +# --cc=COMPILER set the desired build compiler +# --cc-min-version=MAJOR.MINOR Set the minimal version of the target +# compiler. Use --cc-min-version=0.0 to +# support all compiler versions. Default is +# auto detection. +# --cc-bin=BINARY set path to compiler binary +# --cc-abi-flags=FLAGS set compiler ABI flags +# --cxxflags=FLAGS override all compiler flags +# --extra-cxxflags=FLAGS set extra compiler flags +# --ldflags=FLAGS set linker flags +# --ar-command=AR set path to static archive creator +# --ar-options=AR_OPTIONS set options for ar +# --msvc-runtime=RT specify MSVC runtime (MT, MD, MTd, MDd) +# --with-endian=ORDER override byte order guess +# --with-os-features=FEAT specify OS features to use +# --without-os-features=FEAT specify OS features to disable +# --disable-sse2 disable SSE2 intrinsics +# --disable-ssse3 disable SSSE3 intrinsics +# --disable-sse4.1 disable SSE4.1 intrinsics +# --disable-sse4.2 disable SSE4.2 intrinsics +# --disable-avx2 disable AVX2 intrinsics +# --disable-bmi2 disable BMI2 intrinsics +# --disable-rdrand disable RDRAND intrinsics +# --disable-rdseed disable RDSEED intrinsics +# --disable-aes-ni disable AES-NI intrinsics +# --disable-sha-ni disable SHA-NI intrinsics +# --disable-altivec disable AltiVec intrinsics +# --disable-neon disable NEON intrinsics +# --disable-armv8crypto disable ARMv8Crypto intrinsics +# +# Build options: +# --with-debug-info include debug symbols +# --with-sanitizers enable ASan/UBSan checks +# --enable-sanitizers=SAN enable specific sanitizers +# --without-stack-protector disable stack smashing protections +# --with-coverage add coverage info and disable opts +# --with-coverage-info add coverage info +# --disable-shared-library disable building shared library +# --disable-static-library disable building static library +# --optimize-for-size optimize for code size +# --no-optimizations disable all optimizations (for debugging) +# --debug-mode enable debug info, disable optimizations +# --amalgamation use amalgamation to build +# --single-amalgamation-file build single file instead of splitting on +# ABI +# --with-build-dir=DIR setup the build in DIR +# --with-external-includedir=DIR use DIR for external includes +# --with-external-libdir=DIR use DIR for external libs +# --with-sysroot-dir=DIR use DIR for system root while cross- +# compiling +# --with-openmp enable use of OpenMP +# --link-method=METHOD choose how links to include headers are +# created (symlink, hardlink, copy) +# --with-local-config=FILE include the contents of FILE into build.h +# --distribution-info=STRING distribution specific version +# --maintainer-mode Enable extra warnings +# --with-python-versions=N.M where to install botan2.py (def 2.7) +# --with-valgrind use valgrind API +# --unsafe-fuzzer-mode Disable essential checks for testing +# --build-fuzzers=TYPE Build fuzzers (afl, libfuzzer, klee, test) +# --with-fuzzer-lib=LIB additionally link in LIB +# +# Documentation Options: +# --without-documentation Skip building/installing documentation +# --with-sphinx Use Sphinx +# --with-pdf Use Sphinx to generate PDF doc +# --with-rst2man Use rst2man to generate man page +# --with-doxygen Use Doxygen +# +# Module selection: +# --module-policy=POL module policy file (see src/build- +# data/policy) +# --enable-modules=MODS enable specific modules +# --disable-modules=MODS disable specific modules +# --minimized-build minimize build +# --with-bearssl use bearssl +# --with-boost use boost +# --with-bzip2 use bzip2 +# --with-lzma use lzma +# --with-openssl use openssl +# --with-commoncrypto use commoncrypto +# --with-sqlite3 use sqlite3 +# --with-zlib use zlib +# --with-tpm use tpm +# +# Installation options: +# --program-suffix=SUFFIX append string to program names +# --library-suffix=SUFFIX append string to library names +# --prefix=DIR set the install prefix +# --docdir=DIR set the doc install dir +# --bindir=DIR set the binary install dir +# --libdir=DIR set the library install dir +# --mandir=DIR set the install dir for man pages +# --includedir=DIR set the include file install dir +# +# Informational: +# --list-modules list available modules and exit +# --list-os-features list available OS features and exit +# +if("@HUNTER_PACKAGE_CONFIGURATION_TYPES@" STREQUAL "Debug") + list(APPEND configure_opts --debug-mode) +endif() + +if(HUNTER_STATUS_DEBUG) + list(APPEND configure_opts --verbose) +endif() + +if(BUILD_SHARED_LIBS) + list(APPEND configure_opt --disable-static-library) +else() + list(APPEND configure_opts --disable-shared-library) +endif() + +if(WITH_ZLIB) + list(APPEND configure_opts --with-zlib) + hunter_add_package(ZLIB) +endif() + +if(WITH_BZIP2) + list(APPEND configure_opts --with-bzip2) + hunter_add_package(BZip2) +endif() + +if(ENABLE_MODULES) + list(APPEND configure_opts --enable-modules=${ENABLE_MODULES}) +endif() + +list(APPEND configure_opts + --extra-cxxflags=${cxxflags} +) + +if(NOT "${ar}" STREQUAL "") + list(APPEND configure_opts --ar-command=${ar}) +endif() + +set(autotools_build_command "make") +if(NOT "@HUNTER_JOBS_OPTION@" STREQUAL "") + list(APPEND autotools_build_command "-j" "@HUNTER_JOBS_OPTION@") +endif() + +foreach(variant ${configure_architectures}) + + hunter_status_debug("Configure architecture: ${variant}") + + set(cc_abi_flags "${variant}") + set(cpu_flag "${variant}") + set(IPHONE_SDK "iphoneos") + set(additional_configure_opts "") + + if("${variant}" STREQUAL "armv7") + #list(APPEND additional_configure_opts --disable-neon) + message(STATUS "Disable newhope module in armv7 build because of of compiler crash see https://github.com/randombit/botan/issues/2015#issuecomment-508818269") + list(APPEND additional_configure_opts --disable-modules=newhope) + elseif("${variant}" STREQUAL "i386") + set(IPHONE_SDK "iphonesimulator") + elseif("${variant}" STREQUAL "x86_64") + set(IPHONE_SDK "iphonesimulator") + endif() + + hunter_status_debug("Configure options: ${configure_opts} ${additional_configure_opts}") + + ExternalProject_Add( + "@HUNTER_EP_NAME@-${variant}" # Name of the external project. Actually not used set for beautify logging messages + URL + @HUNTER_PACKAGE_URL@ # URL of the package to download + URL_HASH + SHA1=@HUNTER_PACKAGE_SHA1@ # SHA1 hash + DOWNLOAD_DIR + "@HUNTER_PACKAGE_DOWNLOAD_DIR@" # Archive destination location + TLS_VERIFY + "@HUNTER_TLS_VERIFY@" + SOURCE_DIR + "@HUNTER_PACKAGE_SOURCE_DIR@/${variant}" # Unpack directory + INSTALL_DIR + "@HUNTER_INSTALL_PREFIX@" # not used actually (see install command) + CONFIGURE_COMMAND + . "@HUNTER_GLOBAL_SCRIPT_DIR@/clear-all.sh" && + xcrun --sdk ${IPHONE_SDK} "./configure.py" + "--os=ios" + "--cc=clang" + "--cpu=${cpu_flag}" + "--cc-abi-flags=-arch ${cc_abi_flags}" + "--without-documentation" + "--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@" + "--with-external-includedir=@HUNTER_INSTALL_PREFIX@/include" + "--with-external-libdir=@HUNTER_INSTALL_PREFIX@/lib" + ${additional_configure_opts} + ${configure_opts} + BUILD_COMMAND + . "@HUNTER_GLOBAL_SCRIPT_DIR@/clear-all.sh" && + xcrun --sdk ${IPHONE_SDK} make libs + BUILD_IN_SOURCE + 1 + INSTALL_COMMAND + . "@HUNTER_GLOBAL_SCRIPT_DIR@/clear-all.sh" && + xcrun --sdk ${IPHONE_SDK} make install + ) + + add_dependencies( + "@HUNTER_EP_NAME@-ios_universal" + "@HUNTER_EP_NAME@-${variant}" + ) +endforeach() + +string(COMPARE EQUAL "${DEPENDS_ON_PKGCONFIGS}" "" default_pkgconfig) +if(NOT default_pkgconfig) + set(DEPENDS_ON_PACKAGES ${DEPENDS_ON_PKGCONFIGS}) +endif() + +set(PKG_GENERATE_SHARED "${BUILD_SHARED_LIBS}") + +foreach(PKG_CONFIG_MODULE ${PKGCONFIG_EXPORT_TARGETS}) + # Use: + # * DEPENDS_ON_PACKAGES + # * PKG_GENERATE_SHARED + configure_file( + "@HUNTER_GLOBAL_SCRIPT_DIR@/pkgconfig-export-targets.cmake.in" + "@HUNTER_PACKAGE_INSTALL_PREFIX@/lib/cmake/${PKG_CONFIG_MODULE}/${PKG_CONFIG_MODULE}Config.cmake" + @ONLY + ) +endforeach() diff --git a/cmake/projects/botan/schemes/url_sha1_botan_macos.cmake.in b/cmake/projects/botan/schemes/url_sha1_botan_macos.cmake.in new file mode 100644 index 0000000000..a4afcc550c --- /dev/null +++ b/cmake/projects/botan/schemes/url_sha1_botan_macos.cmake.in @@ -0,0 +1,268 @@ +cmake_minimum_required(VERSION 3.0) + +project(Hunter) + +include("@HUNTER_SELF@/cmake/Hunter") + +include(ExternalProject) # ExternalProject_Add + +# some Hunter modules will be used +list(APPEND CMAKE_MODULE_PATH "@HUNTER_SELF@/cmake/modules") + +include(hunter_dump_cmake_flags) +include(hunter_status_debug) +include(hunter_assert_not_empty_string) +include(hunter_unsetvar) +include(hunter_user_error) + +# print this message if HUNTER_STATUS_DEBUG option is ON +hunter_status_debug("Scheme: url_sha1_botan_macos") + +# Check variables is not empty +hunter_assert_not_empty_string("@HUNTER_SELF@") +hunter_assert_not_empty_string("@HUNTER_EP_NAME@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_URL@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SHA1@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_DOWNLOAD_DIR@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SOURCE_DIR@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_INSTALL_PREFIX@") +hunter_assert_not_empty_string("@HUNTER_INSTALL_PREFIX@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_LICENSE_DIR@") +hunter_assert_not_empty_string("@HUNTER_GLOBAL_SCRIPT_DIR@") +hunter_assert_not_empty_string("@HUNTER_TLS_VERIFY@") + +# Skip position independent code flags for macOS +hunter_dump_cmake_flags(SKIP_INCLUDES SKIP_PIC) +# -> CMAKE_CXX_FLAGS +# -> CMAKE_C_FLAGS + +set(configure_architectures @CMAKE_OSX_ARCHITECTURES@) + +if(NOT configure_architectures) + hunter_status_debug("Using default macOS architecture: x86_64") + set(configure_architectures "x86_64") +endif() + +# Usage: configure.py [options] +# +# Options: +# --version show program's version number and exit +# -h, --help show this help message and exit +# --verbose Show debug messages +# --quiet Show only warnings and errors +# +# Target options: +# --cpu=CPU set the target CPU architecture +# --os=OS set the target operating system +# --cc=COMPILER set the desired build compiler +# --cc-min-version=MAJOR.MINOR Set the minimal version of the target +# compiler. Use --cc-min-version=0.0 to +# support all compiler versions. Default is +# auto detection. +# --cc-bin=BINARY set path to compiler binary +# --cc-abi-flags=FLAGS set compiler ABI flags +# --cxxflags=FLAGS override all compiler flags +# --extra-cxxflags=FLAGS set extra compiler flags +# --ldflags=FLAGS set linker flags +# --ar-command=AR set path to static archive creator +# --ar-options=AR_OPTIONS set options for ar +# --msvc-runtime=RT specify MSVC runtime (MT, MD, MTd, MDd) +# --with-endian=ORDER override byte order guess +# --with-os-features=FEAT specify OS features to use +# --without-os-features=FEAT specify OS features to disable +# --disable-sse2 disable SSE2 intrinsics +# --disable-ssse3 disable SSSE3 intrinsics +# --disable-sse4.1 disable SSE4.1 intrinsics +# --disable-sse4.2 disable SSE4.2 intrinsics +# --disable-avx2 disable AVX2 intrinsics +# --disable-bmi2 disable BMI2 intrinsics +# --disable-rdrand disable RDRAND intrinsics +# --disable-rdseed disable RDSEED intrinsics +# --disable-aes-ni disable AES-NI intrinsics +# --disable-sha-ni disable SHA-NI intrinsics +# --disable-altivec disable AltiVec intrinsics +# --disable-neon disable NEON intrinsics +# --disable-armv8crypto disable ARMv8Crypto intrinsics +# +# Build options: +# --with-debug-info include debug symbols +# --with-sanitizers enable ASan/UBSan checks +# --enable-sanitizers=SAN enable specific sanitizers +# --without-stack-protector disable stack smashing protections +# --with-coverage add coverage info and disable opts +# --with-coverage-info add coverage info +# --disable-shared-library disable building shared library +# --disable-static-library disable building static library +# --optimize-for-size optimize for code size +# --no-optimizations disable all optimizations (for debugging) +# --debug-mode enable debug info, disable optimizations +# --amalgamation use amalgamation to build +# --single-amalgamation-file build single file instead of splitting on +# ABI +# --with-build-dir=DIR setup the build in DIR +# --with-external-includedir=DIR use DIR for external includes +# --with-external-libdir=DIR use DIR for external libs +# --with-sysroot-dir=DIR use DIR for system root while cross- +# compiling +# --with-openmp enable use of OpenMP +# --link-method=METHOD choose how links to include headers are +# created (symlink, hardlink, copy) +# --with-local-config=FILE include the contents of FILE into build.h +# --distribution-info=STRING distribution specific version +# --maintainer-mode Enable extra warnings +# --with-python-versions=N.M where to install botan2.py (def 2.7) +# --with-valgrind use valgrind API +# --unsafe-fuzzer-mode Disable essential checks for testing +# --build-fuzzers=TYPE Build fuzzers (afl, libfuzzer, klee, test) +# --with-fuzzer-lib=LIB additionally link in LIB +# +# Documentation Options: +# --without-documentation Skip building/installing documentation +# --with-sphinx Use Sphinx +# --with-pdf Use Sphinx to generate PDF doc +# --with-rst2man Use rst2man to generate man page +# --with-doxygen Use Doxygen +# +# Module selection: +# --module-policy=POL module policy file (see src/build- +# data/policy) +# --enable-modules=MODS enable specific modules +# --disable-modules=MODS disable specific modules +# --minimized-build minimize build +# --with-bearssl use bearssl +# --with-boost use boost +# --with-bzip2 use bzip2 +# --with-lzma use lzma +# --with-openssl use openssl +# --with-commoncrypto use commoncrypto +# --with-sqlite3 use sqlite3 +# --with-zlib use zlib +# --with-tpm use tpm +# +# Installation options: +# --program-suffix=SUFFIX append string to program names +# --library-suffix=SUFFIX append string to library names +# --prefix=DIR set the install prefix +# --docdir=DIR set the doc install dir +# --bindir=DIR set the binary install dir +# --libdir=DIR set the library install dir +# --mandir=DIR set the install dir for man pages +# --includedir=DIR set the include file install dir +# +# Informational: +# --list-modules list available modules and exit +# --list-os-features list available OS features and exit +# +if("@HUNTER_PACKAGE_CONFIGURATION_TYPES@" STREQUAL "Debug") + list(APPEND configure_opts --debug-mode) +endif() + +if(HUNTER_STATUS_DEBUG) + list(APPEND configure_opts --verbose) +endif() + +if(BUILD_SHARED_LIBS) + list(APPEND configure_opt --disable-static-library) +else() + list(APPEND configure_opts --disable-shared-library) +endif() + +if(WITH_ZLIB) + list(APPEND configure_opts --with-zlib) + hunter_add_package(ZLIB) +endif() + +if(WITH_BZIP2) + list(APPEND configure_opts --with-bzip2) + hunter_add_package(BZip2) +endif() + +if(ENABLE_MODULES) + list(APPEND configure_opts --enable-modules=${ENABLE_MODULES}) +endif() + +list(APPEND configure_opts + --extra-cxxflags=${cxxflags} +) + +if(NOT "${ar}" STREQUAL "") + list(APPEND configure_opts --ar-command=${ar}) +endif() + +set(build_command . "@HUNTER_GLOBAL_SCRIPT_DIR@/clear-all.sh" && "make") +if(NOT "@HUNTER_JOBS_OPTION@" STREQUAL "") + list(APPEND build_command "-j" "@HUNTER_JOBS_OPTION@") +endif() + +list(LENGTH configure_architectures configure_architectures_lenght) +if(${configure_architectures_lenght} GREATER 1) + set(arch_flags "") + foreach(arch ${configure_architectures}) + string(APPEND arch_flags "-arch ${arch} ") + endforeach() + list(APPEND configure_opts "--cc-abi-flags=\"-force_cpusubtype_ALL ${arch_flags}\"") +endif() + +set(configure_command . "@HUNTER_GLOBAL_SCRIPT_DIR@/clear-all.sh" && "./configure.py") + +hunter_status_debug("Configure command: ${configure_command}") +hunter_status_debug("Configure architectures: ${configure_architectures}") +hunter_status_debug("Configure options: ${configure_opts}") + +list(GET configure_architectures 0 first_architecture) +ExternalProject_Add( + "@HUNTER_EP_NAME@" # Name of the external project. Actually not used set for beautify logging messages + URL + @HUNTER_PACKAGE_URL@ # URL of the package to download + URL_HASH + SHA1=@HUNTER_PACKAGE_SHA1@ # SHA1 hash + DOWNLOAD_DIR + "@HUNTER_PACKAGE_DOWNLOAD_DIR@" # Archive destination location + TLS_VERIFY + "@HUNTER_TLS_VERIFY@" + SOURCE_DIR + "@HUNTER_PACKAGE_SOURCE_DIR@" # Unpack directory + INSTALL_DIR + "@HUNTER_INSTALL_PREFIX@" # not used actually (see install command) + CONFIGURE_COMMAND + "${configure_command}" + "--os=darwin" + "--cc=clang" + "--cpu=${first_architecture}" + "--without-documentation" + "--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@" + "--with-external-includedir=@HUNTER_INSTALL_PREFIX@/include" + "--with-external-libdir=@HUNTER_INSTALL_PREFIX@/lib" + ${configure_opts} + BUILD_COMMAND + ${build_command} libs + BUILD_IN_SOURCE + 1 + INSTALL_COMMAND + make install + COMMAND # Copy license files + "@CMAKE_COMMAND@" + "-C@HUNTER_ARGS_FILE@" # for 'HUNTER_INSTALL_LICENSE_FILES' + "-Dsrcdir=@HUNTER_PACKAGE_SOURCE_DIR@/${first_architecture}" + "-Ddstdir=@HUNTER_PACKAGE_LICENSE_DIR@" + -P + "@HUNTER_SELF@/scripts/try-copy-license.cmake" +) + +string(COMPARE EQUAL "${DEPENDS_ON_PKGCONFIGS}" "" default_pkgconfig) +if(NOT default_pkgconfig) + set(DEPENDS_ON_PACKAGES ${DEPENDS_ON_PKGCONFIGS}) +endif() + +set(PKG_GENERATE_SHARED "${BUILD_SHARED_LIBS}") + +foreach(PKG_CONFIG_MODULE ${PKGCONFIG_EXPORT_TARGETS}) + # Use: + # * DEPENDS_ON_PACKAGES + # * PKG_GENERATE_SHARED + configure_file( + "@HUNTER_GLOBAL_SCRIPT_DIR@/pkgconfig-export-targets.cmake.in" + "@HUNTER_PACKAGE_INSTALL_PREFIX@/lib/cmake/${PKG_CONFIG_MODULE}/${PKG_CONFIG_MODULE}Config.cmake" + @ONLY + ) +endforeach() diff --git a/cmake/projects/botan/schemes/url_sha1_botan_win.cmake.in b/cmake/projects/botan/schemes/url_sha1_botan_win.cmake.in new file mode 100644 index 0000000000..b27a180c19 --- /dev/null +++ b/cmake/projects/botan/schemes/url_sha1_botan_win.cmake.in @@ -0,0 +1,290 @@ +cmake_minimum_required(VERSION 3.0) + +project(Hunter) + +include("@HUNTER_SELF@/cmake/Hunter") + +include(ExternalProject) # ExternalProject_Add + +# some Hunter modules will be used +list(APPEND CMAKE_MODULE_PATH "@HUNTER_SELF@/cmake/modules") + +include(hunter_status_debug) +include(hunter_assert_not_empty_string) +include(hunter_get_toolchain_binaries) +include(hunter_get_build_flags) +include(hunter_setup_msvc) + +# print this message if HUNTER_STATUS_DEBUG option is ON +hunter_status_debug("Scheme: url_sha1_botan_win") + +# Check variables is not empty +hunter_assert_not_empty_string("@HUNTER_SELF@") +hunter_assert_not_empty_string("@HUNTER_EP_NAME@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_URL@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SHA1@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_DOWNLOAD_DIR@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SOURCE_DIR@") +hunter_assert_not_empty_string("@HUNTER_PACKAGE_INSTALL_PREFIX@") +# TODO These properties are not set in msys-cxx17 build +#hunter_assert_not_empty_string("@HUNTER_MSVC_ARCH@") +#hunter_assert_not_empty_string("@HUNTER_MSVC_VCVARSALL@") +hunter_assert_not_empty_string("@HUNTER_INSTALL_PREFIX@") +hunter_assert_not_empty_string("@HUNTER_TLS_VERIFY@") + +# Build command and options + +hunter_get_toolchain_binaries( + OUT_AR + ar + OUT_AS + as + OUT_LD + ld + OUT_NM + nm + OUT_OBJCOPY + objcopy + OUT_OBJDUMP + objdump + OUT_RANLIB + ranlib + OUT_STRIP + strip + OUT_CPP + cpp + OUT_CC + cc + OUT_CXX + cxx +) + +hunter_get_build_flags( + INSTALL_DIR + "@HUNTER_PACKAGE_INSTALL_PREFIX@" + PACKAGE_CONFIGURATION_TYPES + "@HUNTER_PACKAGE_CONFIGURATION_TYPES@" + OUT_CPPFLAGS + cppflags + OUT_CFLAGS + cflags + OUT_CXXFLAGS + cxxflags + OUT_LDFLAGS + ldflags +) + +hunter_setup_msvc() + +# Usage: configure.py [options] +# +# Options: +# --version show program's version number and exit +# -h, --help show this help message and exit +# --verbose Show debug messages +# --quiet Show only warnings and errors +# +# Target options: +# --cpu=CPU set the target CPU architecture +# --os=OS set the target operating system +# --cc=COMPILER set the desired build compiler +# --cc-min-version=MAJOR.MINOR Set the minimal version of the target +# compiler. Use --cc-min-version=0.0 to +# support all compiler versions. Default is +# auto detection. +# --cc-bin=BINARY set path to compiler binary +# --cc-abi-flags=FLAGS set compiler ABI flags +# --cxxflags=FLAGS override all compiler flags +# --extra-cxxflags=FLAGS set extra compiler flags +# --ldflags=FLAGS set linker flags +# --ar-command=AR set path to static archive creator +# --ar-options=AR_OPTIONS set options for ar +# --msvc-runtime=RT specify MSVC runtime (MT, MD, MTd, MDd) +# --with-endian=ORDER override byte order guess +# --with-os-features=FEAT specify OS features to use +# --without-os-features=FEAT specify OS features to disable +# --disable-sse2 disable SSE2 intrinsics +# --disable-ssse3 disable SSSE3 intrinsics +# --disable-sse4.1 disable SSE4.1 intrinsics +# --disable-sse4.2 disable SSE4.2 intrinsics +# --disable-avx2 disable AVX2 intrinsics +# --disable-bmi2 disable BMI2 intrinsics +# --disable-rdrand disable RDRAND intrinsics +# --disable-rdseed disable RDSEED intrinsics +# --disable-aes-ni disable AES-NI intrinsics +# --disable-sha-ni disable SHA-NI intrinsics +# --disable-altivec disable AltiVec intrinsics +# --disable-neon disable NEON intrinsics +# --disable-armv8crypto disable ARMv8Crypto intrinsics +# +# Build options: +# --with-debug-info include debug symbols +# --with-sanitizers enable ASan/UBSan checks +# --enable-sanitizers=SAN enable specific sanitizers +# --without-stack-protector disable stack smashing protections +# --with-coverage add coverage info and disable opts +# --with-coverage-info add coverage info +# --disable-shared-library disable building shared library +# --disable-static-library disable building static library +# --optimize-for-size optimize for code size +# --no-optimizations disable all optimizations (for debugging) +# --debug-mode enable debug info, disable optimizations +# --amalgamation use amalgamation to build +# --single-amalgamation-file build single file instead of splitting on +# ABI +# --with-build-dir=DIR setup the build in DIR +# --with-external-includedir=DIR use DIR for external includes +# --with-external-libdir=DIR use DIR for external libs +# --with-sysroot-dir=DIR use DIR for system root while cross- +# compiling +# --with-openmp enable use of OpenMP +# --link-method=METHOD choose how links to include headers are +# created (symlink, hardlink, copy) +# --with-local-config=FILE include the contents of FILE into build.h +# --distribution-info=STRING distribution specific version +# --maintainer-mode Enable extra warnings +# --with-python-versions=N.M where to install botan2.py (def 2.7) +# --with-valgrind use valgrind API +# --unsafe-fuzzer-mode Disable essential checks for testing +# --build-fuzzers=TYPE Build fuzzers (afl, libfuzzer, klee, test) +# --with-fuzzer-lib=LIB additionally link in LIB +# +# Documentation Options: +# --without-documentation Skip building/installing documentation +# --with-sphinx Use Sphinx +# --with-pdf Use Sphinx to generate PDF doc +# --with-rst2man Use rst2man to generate man page +# --with-doxygen Use Doxygen +# +# Module selection: +# --module-policy=POL module policy file (see src/build- +# data/policy) +# --enable-modules=MODS enable specific modules +# --disable-modules=MODS disable specific modules +# --minimized-build minimize build +# --with-bearssl use bearssl +# --with-boost use boost +# --with-bzip2 use bzip2 +# --with-lzma use lzma +# --with-openssl use openssl +# --with-commoncrypto use commoncrypto +# --with-sqlite3 use sqlite3 +# --with-zlib use zlib +# --with-tpm use tpm +# +# Installation options: +# --program-suffix=SUFFIX append string to program names +# --library-suffix=SUFFIX append string to library names +# --prefix=DIR set the install prefix +# --docdir=DIR set the doc install dir +# --bindir=DIR set the binary install dir +# --libdir=DIR set the library install dir +# --mandir=DIR set the install dir for man pages +# --includedir=DIR set the include file install dir +# +# Informational: +# --list-modules list available modules and exit +# --list-os-features list available OS features and exit +# +if("@HUNTER_PACKAGE_CONFIGURATION_TYPES@" STREQUAL "Debug") + list(APPEND configure_opts --debug-mode) +endif() + +if(HUNTER_STATUS_DEBUG) + list(APPEND configure_opts --verbose) +endif() + +if(BUILD_SHARED_LIBS) + list(APPEND configure_opt --disable-static-library) +else() + list(APPEND configure_opts --disable-shared-library) +endif() + +if(WITH_ZLIB) + list(APPEND configure_opts --with-zlib) + hunter_add_package(ZLIB) +endif() + +if(WITH_BZIP2) + list(APPEND configure_opts --with-bzip2) + hunter_add_package(BZip2) +endif() + +if(ENABLE_MODULES) + list(APPEND configure_opts --enable-modules=${ENABLE_MODULES}) +endif() + +if("${HUNTER_MSVC_ARCH}" STREQUAL "amd64") + list(APPEND configure_opts --cpu=x64) +else() + list(APPEND configure_opts --cpu=x86) +endif() + +# file(TO_NATIVE_PATH "${cxx}" CXX_BIN) + +# list(APPEND configure_opts +# #--cc-bin=${cxx} +# #"--cc-bin=${CXX_BIN}" +# "--extra-cxxflags=${cxxflags}" +# "--ldflags=${ldflags}" +# #--amalgamation --single-amalgamation-file +# ) + +if(NOT "${ar}" STREQUAL "") + list(APPEND configure_opts --ar-command=${ar}) +endif() + +# MSVS="2015" PLATFORM="x86_amd64" TARGET="shared" +#.\configure.py +#--prefix=c:\users\appveyor\appdata\local\temp\1\botan-install +#--cc=msvc +#--os=windows +#--cpu=x64 or --cpu=x86 +#--cc-bin=sccache cl --no-store-vc-rev + +if(NOT "@HUNTER_MSVC_VCVARSALL@" STREQUAL "") + file(TO_NATIVE_PATH "@HUNTER_MSVC_VCVARSALL@" RUN_MSVC_VCVARSALL) +endif() +file(TO_NATIVE_PATH "@HUNTER_PACKAGE_INSTALL_PREFIX@" INSTALL_PATH) +file(TO_NATIVE_PATH "@HUNTER_PACKAGE_INSTALL_PREFIX@/include" EXTERNAL_INCLUDE) +file(TO_NATIVE_PATH "@HUNTER_PACKAGE_INSTALL_PREFIX@/lib" EXTERNAL_LIB) + +ExternalProject_Add( + @HUNTER_EP_NAME@ # Name of the external project. Actually not used set for beautify logging messages + URL + @HUNTER_PACKAGE_URL@ # URL of the package to download + URL_HASH + SHA1=@HUNTER_PACKAGE_SHA1@ # SHA1 hash + DOWNLOAD_DIR + "@HUNTER_PACKAGE_DOWNLOAD_DIR@" # Archive destination location + TLS_VERIFY + "@HUNTER_TLS_VERIFY@" + SOURCE_DIR + "@HUNTER_PACKAGE_SOURCE_DIR@" # Unpack directory + INSTALL_DIR + "@HUNTER_INSTALL_PREFIX@" # not used actually (see install command) + CONFIGURE_COMMAND + "${RUN_MSVC_VCVARSALL}" "@HUNTER_MSVC_ARCH@" + COMMAND + "./configure.py" + "--os=windows" + "--cc=msvc" + "--without-documentation" + "--prefix=${INSTALL_PATH}" + "--with-external-includedir=${EXTERNAL_INCLUDE}" + "--with-external-libdir=${EXTERNAL_LIB}" + ${configure_opts} + BUILD_COMMAND + nmake libs + BUILD_IN_SOURCE + 1 + INSTALL_COMMAND + nmake install + COMMAND # Copy license files + "@CMAKE_COMMAND@" + "-C@HUNTER_ARGS_FILE@" # for 'HUNTER_INSTALL_LICENSE_FILES' + "-Dsrcdir=@HUNTER_PACKAGE_SOURCE_DIR@" + "-Ddstdir=@HUNTER_PACKAGE_LICENSE_DIR@" + -P + "@HUNTER_SELF@/scripts/try-copy-license.cmake" +) diff --git a/docs/packages/pkg/botan.rst b/docs/packages/pkg/botan.rst new file mode 100644 index 0000000000..0f2e793ae2 --- /dev/null +++ b/docs/packages/pkg/botan.rst @@ -0,0 +1,20 @@ +.. spelling:: + + botan + +.. index:: + single: crypto ; botan + +.. _pkg.botan: + +botan +===== + +- `Official `__ +- `Example `__ +- Added by `Jörg-Christian Böhme `__ (`pr-1922 `__) + +.. literalinclude:: /../examples/botan/CMakeLists.txt + :language: cmake + :start-after: # DOCUMENTATION_START { + :end-before: # DOCUMENTATION_END } diff --git a/examples/botan/CMakeLists.txt b/examples/botan/CMakeLists.txt new file mode 100644 index 0000000000..08a67f6144 --- /dev/null +++ b/examples/botan/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2016-2018, Ruslan Baratov +# All rights reserved. + +cmake_minimum_required(VERSION 3.2) + +# Emulate HunterGate: +# * https://github.com/hunter-packages/gate +include("../common.cmake") + +project(botan-example) + +# DOCUMENTATION_START { +hunter_add_package(botan) +find_package(botan-2 CONFIG REQUIRED) + +add_executable(bte boo.cpp) +target_link_libraries(bte PUBLIC PkgConfig::botan-2) +# DOCUMENTATION_END } diff --git a/examples/botan/boo.cpp b/examples/botan/boo.cpp new file mode 100644 index 0000000000..99f07307c7 --- /dev/null +++ b/examples/botan/boo.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +int main () + { + std::unique_ptr hash1(Botan::HashFunction::create("SHA-256")); + std::unique_ptr hash2(Botan::HashFunction::create("SHA-384")); + std::unique_ptr hash3(Botan::HashFunction::create("SHA-3")); + std::vector buf(2048); + + while(std::cin.good()) + { + //read STDIN to buffer + std::cin.read(reinterpret_cast(buf.data()), buf.size()); + size_t readcount = std::cin.gcount(); + //update hash computations with read data + hash1->update(buf.data(),readcount); + hash2->update(buf.data(),readcount); + hash3->update(buf.data(),readcount); + } + std::cout << "SHA-256: " << Botan::hex_encode(hash1->final()) << std::endl; + std::cout << "SHA-384: " << Botan::hex_encode(hash2->final()) << std::endl; + std::cout << "SHA-3: " << Botan::hex_encode(hash3->final()) << std::endl; + return 0; + }