2016-02-11 14:01:59 +01:00
|
|
|
include(ExternalProject)
|
|
|
|
|
|
|
|
project (scrypt C)
|
|
|
|
|
|
|
|
# This builds the original scrypt source using configure & make. We don't use their build result,
|
|
|
|
# but we use the config.h it creates somewhere on the way (see target_compile_options below).
|
2016-02-12 21:58:37 +01:00
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILDTYPE)
|
2016-02-13 02:07:19 +01:00
|
|
|
set(SCRYPT_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BUILDTYPE}}")
|
2016-02-15 20:01:13 +01:00
|
|
|
|
|
|
|
# Add a default location for homebrew-installed openssl on Mac OS X to include search path
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
set(SCRYPT_CFLAGS "${SCRYPT_CFLAGS} -I/usr/local/opt/openssl/include")
|
|
|
|
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
|
2016-02-11 14:01:59 +01:00
|
|
|
ExternalProject_Add(scrypt_original
|
2017-07-07 16:19:31 +02:00
|
|
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt
|
|
|
|
CONFIGURE_COMMAND /usr/bin/env CC=${CMAKE_C_COMPILER} CFLAGS=${SCRYPT_CFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/configure --prefix=${CMAKE_BINARY_DIR}/vendor/scrypt/
|
2016-02-11 14:01:59 +01:00
|
|
|
PREFIX ${CMAKE_BINARY_DIR}/vendor/scrypt/
|
2016-02-12 21:21:52 +01:00
|
|
|
BUILD_COMMAND ${MAKE}
|
|
|
|
)
|
2016-02-11 14:01:59 +01:00
|
|
|
add_library(${PROJECT_NAME} STATIC
|
2017-07-07 16:19:31 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/lib/crypto/crypto_scrypt.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/lib/crypto/crypto_scrypt_smix.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/libcperciva/util/warnp.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/libcperciva/util/insecure_memzero.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/libcperciva/alg/sha256.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/libcperciva/cpusupport/cpusupport_x86_aesni.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/libcperciva/cpusupport/cpusupport_x86_sse2.c
|
2016-02-12 21:21:52 +01:00
|
|
|
)
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/src/scrypt_original-build/libscrypt_sse2.a
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/src/scrypt_original-build/libcperciva_aesni.a
|
|
|
|
)
|
2016-02-11 14:01:59 +01:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
2017-07-07 16:19:31 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/libcperciva/cpusupport
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/libcperciva/alg
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1/scrypt/libcperciva/util
|
2016-02-12 21:21:52 +01:00
|
|
|
)
|
2016-02-11 14:01:59 +01:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE
|
|
|
|
-DCONFIG_H_FILE=\"${CMAKE_CURRENT_BINARY_DIR}/src/scrypt_original-build/config.h\"
|
2016-10-05 09:07:37 +02:00
|
|
|
-DCPUSUPPORT_CONFIG_FILE=\"${CMAKE_CURRENT_BINARY_DIR}/src/scrypt_original-build/cpusupport-config.h\"
|
2017-09-10 14:35:07 +02:00
|
|
|
-std=gnu99
|
2016-02-12 21:21:52 +01:00
|
|
|
)
|
2016-02-11 14:01:59 +01:00
|
|
|
add_dependencies(${PROJECT_NAME} scrypt_original)
|
2017-07-07 16:19:31 +02:00
|
|
|
target_include_directories(${PROJECT_NAME} SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/scrypt-1.2.1)
|