|
| 1 | +cmake_minimum_required(VERSION 3.0) |
| 2 | + |
| 3 | +project(Hunter) |
| 4 | + |
| 5 | +include("@HUNTER_SELF@/cmake/Hunter") |
| 6 | + |
| 7 | +include(ExternalProject) # ExternalProject_Add |
| 8 | + |
| 9 | +# some Hunter modules will be used |
| 10 | +list(APPEND CMAKE_MODULE_PATH "@HUNTER_SELF@/cmake/modules") |
| 11 | + |
| 12 | +include(hunter_status_debug) |
| 13 | +include(hunter_assert_not_empty_string) |
| 14 | +include(hunter_get_toolchain_binaries) |
| 15 | +include(hunter_get_build_flags) |
| 16 | + |
| 17 | +# print this message if HUNTER_STATUS_DEBUG option is ON |
| 18 | +hunter_status_debug("Scheme: url_sha1_botan") |
| 19 | + |
| 20 | +# Check variables is not empty |
| 21 | +hunter_assert_not_empty_string("@HUNTER_SELF@") |
| 22 | +hunter_assert_not_empty_string("@HUNTER_EP_NAME@") |
| 23 | +hunter_assert_not_empty_string("@HUNTER_PACKAGE_URL@") |
| 24 | +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SHA1@") |
| 25 | +hunter_assert_not_empty_string("@HUNTER_PACKAGE_DOWNLOAD_DIR@") |
| 26 | +hunter_assert_not_empty_string("@HUNTER_PACKAGE_SOURCE_DIR@") |
| 27 | +hunter_assert_not_empty_string("@HUNTER_PACKAGE_INSTALL_PREFIX@") |
| 28 | +hunter_assert_not_empty_string("@HUNTER_INSTALL_PREFIX@") |
| 29 | +hunter_assert_not_empty_string("@HUNTER_TLS_VERIFY@") |
| 30 | + |
| 31 | +# Build command and options |
| 32 | + |
| 33 | +hunter_get_toolchain_binaries( |
| 34 | + OUT_AR |
| 35 | + ar |
| 36 | + OUT_AS |
| 37 | + as |
| 38 | + OUT_LD |
| 39 | + ld |
| 40 | + OUT_NM |
| 41 | + nm |
| 42 | + OUT_OBJCOPY |
| 43 | + objcopy |
| 44 | + OUT_OBJDUMP |
| 45 | + objdump |
| 46 | + OUT_RANLIB |
| 47 | + ranlib |
| 48 | + OUT_STRIP |
| 49 | + strip |
| 50 | + OUT_CPP |
| 51 | + cpp |
| 52 | + OUT_CC |
| 53 | + cc |
| 54 | + OUT_CXX |
| 55 | + cxx |
| 56 | +) |
| 57 | + |
| 58 | +hunter_get_build_flags( |
| 59 | + INSTALL_DIR |
| 60 | + "@HUNTER_PACKAGE_INSTALL_PREFIX@" |
| 61 | + PACKAGE_CONFIGURATION_TYPES |
| 62 | + "@HUNTER_PACKAGE_CONFIGURATION_TYPES@" |
| 63 | + OUT_CPPFLAGS |
| 64 | + cppflags |
| 65 | + OUT_CFLAGS |
| 66 | + cflags |
| 67 | + OUT_CXXFLAGS |
| 68 | + cxxflags |
| 69 | + OUT_LDFLAGS |
| 70 | + ldflags |
| 71 | +) |
| 72 | + |
| 73 | +# Usage: configure.py [options] |
| 74 | +# |
| 75 | +# Options: |
| 76 | +# --version show program's version number and exit |
| 77 | +# -h, --help show this help message and exit |
| 78 | +# --verbose Show debug messages |
| 79 | +# --quiet Show only warnings and errors |
| 80 | +# |
| 81 | +# Target options: |
| 82 | +# --cpu=CPU set the target CPU architecture |
| 83 | +# --os=OS set the target operating system |
| 84 | +# --cc=COMPILER set the desired build compiler |
| 85 | +# --cc-min-version=MAJOR.MINOR Set the minimal version of the target |
| 86 | +# compiler. Use --cc-min-version=0.0 to |
| 87 | +# support all compiler versions. Default is |
| 88 | +# auto detection. |
| 89 | +# --cc-bin=BINARY set path to compiler binary |
| 90 | +# --cc-abi-flags=FLAGS set compiler ABI flags |
| 91 | +# --cxxflags=FLAGS override all compiler flags |
| 92 | +# --extra-cxxflags=FLAGS set extra compiler flags |
| 93 | +# --ldflags=FLAGS set linker flags |
| 94 | +# --ar-command=AR set path to static archive creator |
| 95 | +# --ar-options=AR_OPTIONS set options for ar |
| 96 | +# --msvc-runtime=RT specify MSVC runtime (MT, MD, MTd, MDd) |
| 97 | +# --with-endian=ORDER override byte order guess |
| 98 | +# --with-os-features=FEAT specify OS features to use |
| 99 | +# --without-os-features=FEAT specify OS features to disable |
| 100 | +# --disable-sse2 disable SSE2 intrinsics |
| 101 | +# --disable-ssse3 disable SSSE3 intrinsics |
| 102 | +# --disable-sse4.1 disable SSE4.1 intrinsics |
| 103 | +# --disable-sse4.2 disable SSE4.2 intrinsics |
| 104 | +# --disable-avx2 disable AVX2 intrinsics |
| 105 | +# --disable-bmi2 disable BMI2 intrinsics |
| 106 | +# --disable-rdrand disable RDRAND intrinsics |
| 107 | +# --disable-rdseed disable RDSEED intrinsics |
| 108 | +# --disable-aes-ni disable AES-NI intrinsics |
| 109 | +# --disable-sha-ni disable SHA-NI intrinsics |
| 110 | +# --disable-altivec disable AltiVec intrinsics |
| 111 | +# --disable-neon disable NEON intrinsics |
| 112 | +# --disable-armv8crypto disable ARMv8Crypto intrinsics |
| 113 | +# |
| 114 | +# Build options: |
| 115 | +# --with-debug-info include debug symbols |
| 116 | +# --with-sanitizers enable ASan/UBSan checks |
| 117 | +# --enable-sanitizers=SAN enable specific sanitizers |
| 118 | +# --without-stack-protector disable stack smashing protections |
| 119 | +# --with-coverage add coverage info and disable opts |
| 120 | +# --with-coverage-info add coverage info |
| 121 | +# --disable-shared-library disable building shared library |
| 122 | +# --disable-static-library disable building static library |
| 123 | +# --optimize-for-size optimize for code size |
| 124 | +# --no-optimizations disable all optimizations (for debugging) |
| 125 | +# --debug-mode enable debug info, disable optimizations |
| 126 | +# --amalgamation use amalgamation to build |
| 127 | +# --single-amalgamation-file build single file instead of splitting on |
| 128 | +# ABI |
| 129 | +# --with-build-dir=DIR setup the build in DIR |
| 130 | +# --with-external-includedir=DIR use DIR for external includes |
| 131 | +# --with-external-libdir=DIR use DIR for external libs |
| 132 | +# --with-sysroot-dir=DIR use DIR for system root while cross- |
| 133 | +# compiling |
| 134 | +# --with-openmp enable use of OpenMP |
| 135 | +# --link-method=METHOD choose how links to include headers are |
| 136 | +# created (symlink, hardlink, copy) |
| 137 | +# --with-local-config=FILE include the contents of FILE into build.h |
| 138 | +# --distribution-info=STRING distribution specific version |
| 139 | +# --maintainer-mode Enable extra warnings |
| 140 | +# --with-python-versions=N.M where to install botan2.py (def 2.7) |
| 141 | +# --with-valgrind use valgrind API |
| 142 | +# --unsafe-fuzzer-mode Disable essential checks for testing |
| 143 | +# --build-fuzzers=TYPE Build fuzzers (afl, libfuzzer, klee, test) |
| 144 | +# --with-fuzzer-lib=LIB additionally link in LIB |
| 145 | +# |
| 146 | +# Documentation Options: |
| 147 | +# --without-documentation Skip building/installing documentation |
| 148 | +# --with-sphinx Use Sphinx |
| 149 | +# --with-pdf Use Sphinx to generate PDF doc |
| 150 | +# --with-rst2man Use rst2man to generate man page |
| 151 | +# --with-doxygen Use Doxygen |
| 152 | +# |
| 153 | +# Module selection: |
| 154 | +# --module-policy=POL module policy file (see src/build- |
| 155 | +# data/policy) |
| 156 | +# --enable-modules=MODS enable specific modules |
| 157 | +# --disable-modules=MODS disable specific modules |
| 158 | +# --minimized-build minimize build |
| 159 | +# --with-bearssl use bearssl |
| 160 | +# --with-boost use boost |
| 161 | +# --with-bzip2 use bzip2 |
| 162 | +# --with-lzma use lzma |
| 163 | +# --with-openssl use openssl |
| 164 | +# --with-commoncrypto use commoncrypto |
| 165 | +# --with-sqlite3 use sqlite3 |
| 166 | +# --with-zlib use zlib |
| 167 | +# --with-tpm use tpm |
| 168 | +# |
| 169 | +# Installation options: |
| 170 | +# --program-suffix=SUFFIX append string to program names |
| 171 | +# --library-suffix=SUFFIX append string to library names |
| 172 | +# --prefix=DIR set the install prefix |
| 173 | +# --docdir=DIR set the doc install dir |
| 174 | +# --bindir=DIR set the binary install dir |
| 175 | +# --libdir=DIR set the library install dir |
| 176 | +# --mandir=DIR set the install dir for man pages |
| 177 | +# --includedir=DIR set the include file install dir |
| 178 | +# |
| 179 | +# Informational: |
| 180 | +# --list-modules list available modules and exit |
| 181 | +# --list-os-features list available OS features and exit |
| 182 | +# |
| 183 | + |
| 184 | +if(ANDROID) |
| 185 | + list(APPEND configure_opts --os=android) |
| 186 | + set(cpu_flag "${CMAKE_ANDROID_ARCH_ABI}") |
| 187 | + if("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL "arm64-v8a") |
| 188 | + set(cpu_flag "arm64") |
| 189 | + elseif("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL "armeabi-v7a") |
| 190 | + set(cpu_flag "armv7-a") |
| 191 | + elseif("${CMAKE_ANDROID_ARCH_ABI}" STREQUAL "armeabi") |
| 192 | + set(cpu_flag "arm") |
| 193 | + endif() |
| 194 | + |
| 195 | + list(APPEND configure_opts --cpu=${cpu_flag}) |
| 196 | +elseif(UNIX) |
| 197 | + list(APPEND configure_opts --os=linux) |
| 198 | +endif() |
| 199 | + |
| 200 | +if("@HUNTER_PACKAGE_CONFIGURATION_TYPES@" STREQUAL "Debug") |
| 201 | + list(APPEND configure_opts --debug-mode) |
| 202 | +endif() |
| 203 | + |
| 204 | +if(HUNTER_STATUS_DEBUG) |
| 205 | + list(APPEND configure_opts --verbose) |
| 206 | +endif() |
| 207 | + |
| 208 | +if(BUILD_SHARED_LIBS) |
| 209 | + list(APPEND configure_opt --disable-static-library) |
| 210 | +else() |
| 211 | + list(APPEND configure_opts --disable-shared-library) |
| 212 | +endif() |
| 213 | + |
| 214 | +if(WITH_ZLIB) |
| 215 | + list(APPEND configure_opts --with-zlib) |
| 216 | + hunter_add_package(ZLIB) |
| 217 | +endif() |
| 218 | + |
| 219 | +if(WITH_BZIP2) |
| 220 | + list(APPEND configure_opts --with-bzip2) |
| 221 | + hunter_add_package(BZip2) |
| 222 | +endif() |
| 223 | + |
| 224 | +if(ENABLE_MODULES) |
| 225 | + list(APPEND configure_opts --enable-modules=${ENABLE_MODULES}) |
| 226 | +endif() |
| 227 | + |
| 228 | +list(APPEND configure_opts |
| 229 | + --cc-bin=${cxx} |
| 230 | + --extra-cxxflags=${cxxflags} |
| 231 | + "--ldflags=${cxxflags} ${ldflags}" |
| 232 | +) |
| 233 | + |
| 234 | +if(NOT "${ar}" STREQUAL "") |
| 235 | + list(APPEND configure_opts --ar-command=${ar}) |
| 236 | +endif() |
| 237 | + |
| 238 | +set(autotools_build_command "make") |
| 239 | +if(MINGW) |
| 240 | + set(autotools_build_command "nmake") |
| 241 | +endif() |
| 242 | + |
| 243 | +if(NOT "@HUNTER_JOBS_OPTION@" STREQUAL "") |
| 244 | + list(APPEND autotools_build_command "-j" "@HUNTER_JOBS_OPTION@") |
| 245 | +endif() |
| 246 | + |
| 247 | +ExternalProject_Add( |
| 248 | + @HUNTER_EP_NAME@ # Name of the external project. Actually not used set for beautify logging messages |
| 249 | + URL |
| 250 | + @HUNTER_PACKAGE_URL@ # URL of the package to download |
| 251 | + URL_HASH |
| 252 | + SHA1=@HUNTER_PACKAGE_SHA1@ # SHA1 hash |
| 253 | + DOWNLOAD_DIR |
| 254 | + "@HUNTER_PACKAGE_DOWNLOAD_DIR@" # Archive destination location |
| 255 | + TLS_VERIFY |
| 256 | + "@HUNTER_TLS_VERIFY@" |
| 257 | + SOURCE_DIR |
| 258 | + "@HUNTER_PACKAGE_SOURCE_DIR@" # Unpack directory |
| 259 | + INSTALL_DIR |
| 260 | + "@HUNTER_INSTALL_PREFIX@" # not used actually (see install command) |
| 261 | + CONFIGURE_COMMAND |
| 262 | + "./configure.py" |
| 263 | + "--without-documentation" |
| 264 | + "--prefix=@HUNTER_PACKAGE_INSTALL_PREFIX@" |
| 265 | + "--with-external-includedir=@HUNTER_INSTALL_PREFIX@/include" |
| 266 | + "--with-external-libdir=@HUNTER_INSTALL_PREFIX@/lib" |
| 267 | + ${configure_opts} |
| 268 | + BUILD_COMMAND |
| 269 | + ${autotools_build_command} libs |
| 270 | + BUILD_IN_SOURCE |
| 271 | + 1 |
| 272 | + INSTALL_COMMAND |
| 273 | + make install |
| 274 | + COMMAND # Copy license files |
| 275 | + "@CMAKE_COMMAND@" |
| 276 | + "-C@HUNTER_ARGS_FILE@" # for 'HUNTER_INSTALL_LICENSE_FILES' |
| 277 | + "-Dsrcdir=@HUNTER_PACKAGE_SOURCE_DIR@" |
| 278 | + "-Ddstdir=@HUNTER_PACKAGE_LICENSE_DIR@" |
| 279 | + -P |
| 280 | + "@HUNTER_SELF@/scripts/try-copy-license.cmake" |
| 281 | +) |
| 282 | + |
| 283 | +string(COMPARE EQUAL "${DEPENDS_ON_PKGCONFIGS}" "" default_pkgconfig) |
| 284 | +if(NOT default_pkgconfig) |
| 285 | + set(DEPENDS_ON_PACKAGES ${DEPENDS_ON_PKGCONFIGS}) |
| 286 | +endif() |
| 287 | + |
| 288 | +set(PKG_GENERATE_SHARED "${BUILD_SHARED_LIBS}") |
| 289 | + |
| 290 | +foreach(PKG_CONFIG_MODULE ${PKGCONFIG_EXPORT_TARGETS}) |
| 291 | + # Use: |
| 292 | + # * DEPENDS_ON_PACKAGES |
| 293 | + # * PKG_GENERATE_SHARED |
| 294 | + configure_file( |
| 295 | + "@HUNTER_GLOBAL_SCRIPT_DIR@/pkgconfig-export-targets.cmake.in" |
| 296 | + "@HUNTER_PACKAGE_INSTALL_PREFIX@/lib/cmake/${PKG_CONFIG_MODULE}/${PKG_CONFIG_MODULE}Config.cmake" |
| 297 | + @ONLY |
| 298 | + ) |
| 299 | +endforeach() |
0 commit comments