mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
cmake: allow to embed LZ4
This commit is contained in:
parent
5b656ad4b0
commit
03ae05a345
2 changed files with 89 additions and 22 deletions
|
@ -96,11 +96,12 @@ if (CMAKE_TOOLCHAIN_FILE)
|
||||||
endif (ANDROID)
|
endif (ANDROID)
|
||||||
set(EMBED_READLINE ON)
|
set(EMBED_READLINE ON)
|
||||||
set(EMBED_BZIP2 ON)
|
set(EMBED_BZIP2 ON)
|
||||||
|
set(EMBED_LZ4 ON)
|
||||||
endif (CMAKE_TOOLCHAIN_FILE)
|
endif (CMAKE_TOOLCHAIN_FILE)
|
||||||
|
|
||||||
if (EMBED_READLINE OR EMBED_BZIP2)
|
if (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4)
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
endif (EMBED_READLINE OR EMBED_BZIP2)
|
endif (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4)
|
||||||
|
|
||||||
if (NOT SKIPREADLINE EQUAL 1)
|
if (NOT SKIPREADLINE EQUAL 1)
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
@ -184,8 +185,29 @@ else(EMBED_BZIP2)
|
||||||
find_package (BZip2 REQUIRED)
|
find_package (BZip2 REQUIRED)
|
||||||
endif(EMBED_BZIP2)
|
endif(EMBED_BZIP2)
|
||||||
|
|
||||||
find_path(LZ4_INCLUDE_DIRS lz4frame.h)
|
if(EMBED_LZ4)
|
||||||
find_library(LZ4_LIBRARIES lz4)
|
cmake_policy(SET CMP0114 NEW)
|
||||||
|
set(LZ4_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4)
|
||||||
|
# Specify SOURCE_DIR will cause some errors
|
||||||
|
ExternalProject_Add(lz4
|
||||||
|
GIT_REPOSITORY https://android.googlesource.com/platform/external/lz4
|
||||||
|
GIT_TAG platform-tools-30.0.2
|
||||||
|
PREFIX deps/lz4
|
||||||
|
# SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/lz4
|
||||||
|
CONFIGURE_COMMAND mkdir -p ${LZ4_BUILD_DIR} && git archive --format tar HEAD | tar -C ${LZ4_BUILD_DIR} -x
|
||||||
|
BUILD_IN_SOURCE ON
|
||||||
|
BUILD_COMMAND make -C ${LZ4_BUILD_DIR}/lib -j4 CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} liblz4.a
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
LOG_DOWNLOAD ON
|
||||||
|
)
|
||||||
|
ExternalProject_Add_StepTargets(lz4 configure build install)
|
||||||
|
set(LZ4_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4/lib)
|
||||||
|
set(LZ4_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4/lib/liblz4.a)
|
||||||
|
set(LZ4_FOUND ON)
|
||||||
|
else(EMBED_LZ4)
|
||||||
|
find_path(LZ4_INCLUDE_DIRS lz4frame.h)
|
||||||
|
find_library(LZ4_LIBRARIES lz4)
|
||||||
|
endif(EMBED_LZ4)
|
||||||
|
|
||||||
if (LZ4_INCLUDE_DIRS AND LZ4_LIBRARIES)
|
if (LZ4_INCLUDE_DIRS AND LZ4_LIBRARIES)
|
||||||
set(LZ4_FOUND ON)
|
set(LZ4_FOUND ON)
|
||||||
|
@ -502,16 +524,24 @@ else (SKIPBT EQUAL 1)
|
||||||
endif (BLUEZ_FOUND)
|
endif (BLUEZ_FOUND)
|
||||||
endif(SKIPBT EQUAL 1)
|
endif(SKIPBT EQUAL 1)
|
||||||
|
|
||||||
if (EMBED_BZIP2)
|
if (BZIP2_FOUND)
|
||||||
message(STATUS "Bzip2 library: embedded")
|
if (EMBED_BZIP2)
|
||||||
else (EMBED_BZIP2)
|
message(STATUS "Bzip2 library: embedded")
|
||||||
message(STATUS "Bzip2 library: system library found")
|
else (EMBED_BZIP2)
|
||||||
endif (EMBED_BZIP2)
|
message(STATUS "Bzip2 library: system library found")
|
||||||
|
endif (EMBED_BZIP2)
|
||||||
|
else (BZIP2_FOUND)
|
||||||
|
message(SEND_ERROR "Bzip2 library: Bzip2 not found")
|
||||||
|
endif (BZIP2_FOUND)
|
||||||
|
|
||||||
if (LZ4_FOUND)
|
if (LZ4_FOUND)
|
||||||
message(STATUS "LZ4 library: system library found")
|
if (EMBED_LZ4)
|
||||||
|
message(STATUS "LZ4 library: embedded")
|
||||||
|
else (EMBED_LZ4)
|
||||||
|
message(STATUS "LZ4 library: system library found")
|
||||||
|
endif (EMBED_LZ4)
|
||||||
else (LZ4_FOUND)
|
else (LZ4_FOUND)
|
||||||
message(SEND_ERROR "LZ4 library: system library not found and no local library implemented")
|
message(SEND_ERROR "LZ4 library: LZ4 not found")
|
||||||
endif (LZ4_FOUND)
|
endif (LZ4_FOUND)
|
||||||
|
|
||||||
if (SKIPJANSSONSYSTEM EQUAL 1)
|
if (SKIPJANSSONSYSTEM EQUAL 1)
|
||||||
|
@ -612,6 +642,9 @@ endif (EMBED_READLINE)
|
||||||
if (EMBED_BZIP2)
|
if (EMBED_BZIP2)
|
||||||
add_dependencies(proxmark3 bzip2)
|
add_dependencies(proxmark3 bzip2)
|
||||||
endif (EMBED_BZIP2)
|
endif (EMBED_BZIP2)
|
||||||
|
if (EMBED_LZ4)
|
||||||
|
add_dependencies(proxmark3 lz4)
|
||||||
|
endif (EMBED_LZ4)
|
||||||
|
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
||||||
|
|
|
@ -97,11 +97,12 @@ if (CMAKE_TOOLCHAIN_FILE)
|
||||||
endif (ANDROID)
|
endif (ANDROID)
|
||||||
set(EMBED_READLINE ON)
|
set(EMBED_READLINE ON)
|
||||||
set(EMBED_BZIP2 ON)
|
set(EMBED_BZIP2 ON)
|
||||||
|
set(EMBED_LZ4 ON)
|
||||||
endif (CMAKE_TOOLCHAIN_FILE)
|
endif (CMAKE_TOOLCHAIN_FILE)
|
||||||
|
|
||||||
if (EMBED_READLINE OR EMBED_BZIP2)
|
if (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4)
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
endif (EMBED_READLINE OR EMBED_BZIP2)
|
endif (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4)
|
||||||
|
|
||||||
if (NOT SKIPREADLINE EQUAL 1)
|
if (NOT SKIPREADLINE EQUAL 1)
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
@ -163,6 +164,7 @@ if (NOT SKIPJANSSONSYSTEM EQUAL 1)
|
||||||
endif (NOT SKIPJANSSONSYSTEM EQUAL 1)
|
endif (NOT SKIPJANSSONSYSTEM EQUAL 1)
|
||||||
|
|
||||||
if(EMBED_BZIP2)
|
if(EMBED_BZIP2)
|
||||||
|
cmake_policy(SET CMP0114 NEW)
|
||||||
set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
|
set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
|
||||||
ExternalProject_Add(bzip2
|
ExternalProject_Add(bzip2
|
||||||
GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2
|
GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2
|
||||||
|
@ -183,8 +185,29 @@ else(EMBED_BZIP2)
|
||||||
find_package (BZip2 REQUIRED)
|
find_package (BZip2 REQUIRED)
|
||||||
endif(EMBED_BZIP2)
|
endif(EMBED_BZIP2)
|
||||||
|
|
||||||
find_path(LZ4_INCLUDE_DIRS lz4frame.h)
|
if(EMBED_LZ4)
|
||||||
find_library(LZ4_LIBRARIES lz4)
|
cmake_policy(SET CMP0114 NEW)
|
||||||
|
set(LZ4_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4)
|
||||||
|
# Specify SOURCE_DIR will cause some errors
|
||||||
|
ExternalProject_Add(lz4
|
||||||
|
GIT_REPOSITORY https://android.googlesource.com/platform/external/lz4
|
||||||
|
GIT_TAG platform-tools-30.0.2
|
||||||
|
PREFIX deps/lz4
|
||||||
|
# SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/lz4
|
||||||
|
CONFIGURE_COMMAND mkdir -p ${LZ4_BUILD_DIR} && git archive --format tar HEAD | tar -C ${LZ4_BUILD_DIR} -x
|
||||||
|
BUILD_IN_SOURCE ON
|
||||||
|
BUILD_COMMAND make -C ${LZ4_BUILD_DIR}/lib -j4 CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} liblz4.a
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
LOG_DOWNLOAD ON
|
||||||
|
)
|
||||||
|
ExternalProject_Add_StepTargets(lz4 configure build install)
|
||||||
|
set(LZ4_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4/lib)
|
||||||
|
set(LZ4_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4/lib/liblz4.a)
|
||||||
|
set(LZ4_FOUND ON)
|
||||||
|
else(EMBED_LZ4)
|
||||||
|
find_path(LZ4_INCLUDE_DIRS lz4frame.h)
|
||||||
|
find_library(LZ4_LIBRARIES lz4)
|
||||||
|
endif(EMBED_LZ4)
|
||||||
|
|
||||||
if (LZ4_INCLUDE_DIRS AND LZ4_LIBRARIES)
|
if (LZ4_INCLUDE_DIRS AND LZ4_LIBRARIES)
|
||||||
set(LZ4_FOUND ON)
|
set(LZ4_FOUND ON)
|
||||||
|
@ -501,16 +524,24 @@ else (SKIPBT EQUAL 1)
|
||||||
endif (BLUEZ_FOUND)
|
endif (BLUEZ_FOUND)
|
||||||
endif(SKIPBT EQUAL 1)
|
endif(SKIPBT EQUAL 1)
|
||||||
|
|
||||||
if (EMBED_BZIP2)
|
if (BZIP2_FOUND)
|
||||||
message(STATUS "Bzip2 library: embedded")
|
if (EMBED_BZIP2)
|
||||||
else (EMBED_BZIP2)
|
message(STATUS "Bzip2 library: embedded")
|
||||||
message(STATUS "Bzip2 library: system library found")
|
else (EMBED_BZIP2)
|
||||||
endif (EMBED_BZIP2)
|
message(STATUS "Bzip2 library: system library found")
|
||||||
|
endif (EMBED_BZIP2)
|
||||||
|
else (BZIP2_FOUND)
|
||||||
|
message(SEND_ERROR "Bzip2 library: Bzip2 not found")
|
||||||
|
endif (BZIP2_FOUND)
|
||||||
|
|
||||||
if (LZ4_FOUND)
|
if (LZ4_FOUND)
|
||||||
message(STATUS "LZ4 library: system library found")
|
if (EMBED_LZ4)
|
||||||
|
message(STATUS "LZ4 library: embedded")
|
||||||
|
else (EMBED_LZ4)
|
||||||
|
message(STATUS "LZ4 library: system library found")
|
||||||
|
endif (EMBED_LZ4)
|
||||||
else (LZ4_FOUND)
|
else (LZ4_FOUND)
|
||||||
message(SEND_ERROR "LZ4 library: system library not found and no local library implemented")
|
message(SEND_ERROR "LZ4 library: LZ4 not found")
|
||||||
endif (LZ4_FOUND)
|
endif (LZ4_FOUND)
|
||||||
|
|
||||||
if (SKIPJANSSONSYSTEM EQUAL 1)
|
if (SKIPJANSSONSYSTEM EQUAL 1)
|
||||||
|
@ -611,6 +642,9 @@ endif (EMBED_READLINE)
|
||||||
if (EMBED_BZIP2)
|
if (EMBED_BZIP2)
|
||||||
add_dependencies(pm3rrg_rdv4 bzip2)
|
add_dependencies(pm3rrg_rdv4 bzip2)
|
||||||
endif (EMBED_BZIP2)
|
endif (EMBED_BZIP2)
|
||||||
|
if (EMBED_LZ4)
|
||||||
|
add_dependencies(pm3rrg_rdv4 lz4)
|
||||||
|
endif (EMBED_LZ4)
|
||||||
|
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue