Skip to content

Instantly share code, notes, and snippets.

@snowden2
Created April 4, 2019 14:34
Show Gist options
  • Save snowden2/d8e827bd7ad66bacdb8f4e58e1ee7e54 to your computer and use it in GitHub Desktop.
Save snowden2/d8e827bd7ad66bacdb8f4e58e1ee7e54 to your computer and use it in GitHub Desktop.
CMakeFile
cmake_minimum_required(VERSION 3.6)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic" )
#test for ANDROID and look for stuff not relevant to android.
if(NOT ANDROID)
#jni is available by default on android
find_package(JNI REQUIRED)
include_directories(${JNI_INCLUDE_DIRS})
endif()
set( LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib/pc CACHE PATH
"Single Directory for all Libraries")
add_library(crypto-lib SHARED src/main/cpp/crypto-lib.cpp
src/main/cpp/RsaEncryptor.cpp
src/main/cpp/Converter.cpp
src/main/cpp/crypto++/cryptlib.cpp
src/main/cpp/crypto++/cpu.cpp
src/main/cpp/crypto++/integer.cpp
src/main/cpp/crypto++/3way.cpp
src/main/cpp/crypto++/adler32.cpp
src/main/cpp/crypto++/algebra.cpp
src/main/cpp/crypto++/algparam.cpp
src/main/cpp/crypto++/arc4.cpp
src/main/cpp/crypto++/aria-simd.cpp
src/main/cpp/crypto++/aria.cpp
src/main/cpp/crypto++/ariatab.cpp
src/main/cpp/crypto++/asn.cpp
src/main/cpp/crypto++/authenc.cpp
src/main/cpp/crypto++/base32.cpp
src/main/cpp/crypto++/base64.cpp
src/main/cpp/crypto++/basecode.cpp
src/main/cpp/crypto++/bfinit.cpp
src/main/cpp/crypto++/blake2-simd.cpp
src/main/cpp/crypto++/blake2.cpp
src/main/cpp/crypto++/blowfish.cpp
src/main/cpp/crypto++/blumshub.cpp
src/main/cpp/crypto++/camellia.cpp
src/main/cpp/crypto++/cast.cpp
src/main/cpp/crypto++/casts.cpp
src/main/cpp/crypto++/cbcmac.cpp
src/main/cpp/crypto++/ccm.cpp
src/main/cpp/crypto++/chacha.cpp
src/main/cpp/crypto++/channels.cpp
src/main/cpp/crypto++/cmac.cpp
src/main/cpp/crypto++/crc-simd.cpp
src/main/cpp/crypto++/crc.cpp
src/main/cpp/crypto++/default.cpp
src/main/cpp/crypto++/des.cpp
src/main/cpp/crypto++/dessp.cpp
src/main/cpp/crypto++/dh.cpp
src/main/cpp/crypto++/dh2.cpp
src/main/cpp/crypto++/dll.cpp
src/main/cpp/crypto++/dsa.cpp
src/main/cpp/crypto++/eax.cpp
src/main/cpp/crypto++/ec2n.cpp
src/main/cpp/crypto++/eccrypto.cpp
src/main/cpp/crypto++/ecp.cpp
src/main/cpp/crypto++/elgamal.cpp
src/main/cpp/crypto++/emsa2.cpp
src/main/cpp/crypto++/eprecomp.cpp
src/main/cpp/crypto++/esign.cpp
src/main/cpp/crypto++/files.cpp
src/main/cpp/crypto++/filters.cpp
src/main/cpp/crypto++/fips140.cpp
src/main/cpp/crypto++/fipstest.cpp
src/main/cpp/crypto++/gcm-simd.cpp
src/main/cpp/crypto++/gcm.cpp
src/main/cpp/crypto++/gf256.cpp
src/main/cpp/crypto++/gf2_32.cpp
src/main/cpp/crypto++/gf2n.cpp
src/main/cpp/crypto++/gfpcrypt.cpp
src/main/cpp/crypto++/gost.cpp
src/main/cpp/crypto++/gzip.cpp
src/main/cpp/crypto++/hex.cpp
src/main/cpp/crypto++/hmac.cpp
src/main/cpp/crypto++/hrtimer.cpp
src/main/cpp/crypto++/ida.cpp
src/main/cpp/crypto++/idea.cpp
src/main/cpp/crypto++/iterhash.cpp
src/main/cpp/crypto++/kalyna.cpp
src/main/cpp/crypto++/kalynatab.cpp
src/main/cpp/crypto++/keccak.cpp
src/main/cpp/crypto++/luc.cpp
src/main/cpp/crypto++/mars.cpp
src/main/cpp/crypto++/marss.cpp
src/main/cpp/crypto++/md2.cpp
src/main/cpp/crypto++/md4.cpp
src/main/cpp/crypto++/md5.cpp
src/main/cpp/crypto++/misc.cpp
src/main/cpp/crypto++/modes.cpp
src/main/cpp/crypto++/mqueue.cpp
src/main/cpp/crypto++/mqv.cpp
src/main/cpp/crypto++/nbtheory.cpp
src/main/cpp/crypto++/neon-simd.cpp
src/main/cpp/crypto++/network.cpp
src/main/cpp/crypto++/oaep.cpp
# No idea where this file is meant to come from
# ospstore.cpp
src/main/cpp/crypto++/osrng.cpp
src/main/cpp/crypto++/panama.cpp
src/main/cpp/crypto++/pkcspad.cpp
src/main/cpp/crypto++/poly1305.cpp
src/main/cpp/crypto++/polynomi.cpp
src/main/cpp/crypto++/pssr.cpp
src/main/cpp/crypto++/pubkey.cpp
src/main/cpp/crypto++/queue.cpp
src/main/cpp/crypto++/rabin.cpp
src/main/cpp/crypto++/randpool.cpp
src/main/cpp/crypto++/rc2.cpp
src/main/cpp/crypto++/rc5.cpp
src/main/cpp/crypto++/rc6.cpp
src/main/cpp/crypto++/rdrand.cpp
src/main/cpp/crypto++/rdtables.cpp
src/main/cpp/crypto++/rijndael.cpp
src/main/cpp/crypto++/ripemd.cpp
src/main/cpp/crypto++/rng.cpp
src/main/cpp/crypto++/rsa.cpp
src/main/cpp/crypto++/rw.cpp
src/main/cpp/crypto++/safer.cpp
src/main/cpp/crypto++/salsa.cpp
src/main/cpp/crypto++/scrypt.cpp
src/main/cpp/crypto++/seal.cpp
src/main/cpp/crypto++/seed.cpp
src/main/cpp/crypto++/serpent.cpp
src/main/cpp/crypto++/sha-simd.cpp
src/main/cpp/crypto++/sha.cpp
src/main/cpp/crypto++/sha3.cpp
src/main/cpp/crypto++/shacal2-simd.cpp
src/main/cpp/crypto++/shacal2.cpp
src/main/cpp/crypto++/shark.cpp
src/main/cpp/crypto++/sharkbox.cpp
src/main/cpp/crypto++/skipjack.cpp
src/main/cpp/crypto++/socketft.cpp
src/main/cpp/crypto++/sosemanuk.cpp
src/main/cpp/crypto++/square.cpp
src/main/cpp/crypto++/squaretb.cpp
src/main/cpp/crypto++/strciphr.cpp
src/main/cpp/crypto++/tea.cpp
src/main/cpp/crypto++/tftables.cpp
src/main/cpp/crypto++/threefish.cpp
src/main/cpp/crypto++/tiger.cpp
src/main/cpp/crypto++/tigertab.cpp
src/main/cpp/crypto++/trdlocal.cpp
src/main/cpp/crypto++/ttmac.cpp
src/main/cpp/crypto++/twofish.cpp
src/main/cpp/crypto++/vmac.cpp
src/main/cpp/crypto++/wait.cpp
src/main/cpp/crypto++/wake.cpp
src/main/cpp/crypto++/whrlpool.cpp
src/main/cpp/crypto++/xtr.cpp
src/main/cpp/crypto++/xtrcrypt.cpp
src/main/cpp/crypto++/zdeflate.cpp
src/main/cpp/crypto++/zinflate.cpp
src/main/cpp/crypto++/zlib.cpp
# i586 only
src/main/cpp/crypto++/rijndael-simd.cpp
# AESNI or ARMv7a/ARMv8a available
src/main/cpp/crypto++/sse-simd.cpp
)
target_include_directories(crypto-lib PUBLIC .)
target_compile_options(crypto-lib PRIVATE -fPIC)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
target_compile_options(crypto-lib PRIVATE
-Wno-class-memaccess
-Wno-unknown-pragmas
)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
target_compile_options(crypto-lib PRIVATE
-Wno-keyword-macro
-Wno-unused-const-variable
-Wno-unused-private-field
)
endif()
if("${ANDROID_ABI}" STREQUAL "")
# This assumes that we're going with x86 like systems if we're not building Android
target_compile_options(crypto-lib
PUBLIC -maes -mpclmul -msha -msse4.1 -msse4.2 -mssse3)
install(TARGETS crypto-lib LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
else()
include(AndroidNdkModules)
android_ndk_import_module_cpufeatures()
target_link_libraries(crypto-lib cpufeatures)
if(${ANDROID_ABI} MATCHES "^x86")
target_compile_options(crypto-lib PUBLIC
-maes -mpclmul -msha -msse4.1 -msse4.2 -mssse3)
# Do this for Android builds for now as the NDK is broken
target_compile_definitions(crypto-lib PRIVATE CRYPTOPP_DISABLE_ASM)
message(WARNING "Disabled x86 crypto ASM")
elseif(${ANDROID_ABI} STREQUAL "armeabi-v7a")
# Setting NEON only really makes sense for this ABI
target_compile_options(crypto-lib PUBLIC -mfpu=neon)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
# There isn't anything that we need to do for this architecture
else()
message(FATAL_ERROR "Can't determine android architecture " ${ANDROID_ABI})
endif()
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment