diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 9ea004590..be4e00a93 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -96,11 +96,12 @@ if (CMAKE_TOOLCHAIN_FILE) endif (ANDROID) set(EMBED_READLINE ON) set(EMBED_BZIP2 ON) + set(EMBED_LZ4 ON) endif (CMAKE_TOOLCHAIN_FILE) -if (EMBED_READLINE OR EMBED_BZIP2) +if (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4) include(ExternalProject) -endif (EMBED_READLINE OR EMBED_BZIP2) +endif (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4) if (NOT SKIPREADLINE EQUAL 1) if (APPLE) @@ -184,8 +185,29 @@ else(EMBED_BZIP2) find_package (BZip2 REQUIRED) endif(EMBED_BZIP2) -find_path(LZ4_INCLUDE_DIRS lz4frame.h) -find_library(LZ4_LIBRARIES lz4) +if(EMBED_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) set(LZ4_FOUND ON) @@ -502,16 +524,24 @@ else (SKIPBT EQUAL 1) endif (BLUEZ_FOUND) endif(SKIPBT EQUAL 1) -if (EMBED_BZIP2) - message(STATUS "Bzip2 library: embedded") -else (EMBED_BZIP2) - message(STATUS "Bzip2 library: system library found") -endif (EMBED_BZIP2) +if (BZIP2_FOUND) + if (EMBED_BZIP2) + message(STATUS "Bzip2 library: embedded") + else (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) - 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) - 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) if (SKIPJANSSONSYSTEM EQUAL 1) @@ -612,6 +642,9 @@ endif (EMBED_READLINE) if (EMBED_BZIP2) add_dependencies(proxmark3 bzip2) endif (EMBED_BZIP2) +if (EMBED_LZ4) + add_dependencies(proxmark3 lz4) +endif (EMBED_LZ4) if (MINGW) # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z) diff --git a/client/experimental_lib/CMakeLists.txt b/client/experimental_lib/CMakeLists.txt index 0cd148fa3..cec361446 100644 --- a/client/experimental_lib/CMakeLists.txt +++ b/client/experimental_lib/CMakeLists.txt @@ -97,11 +97,12 @@ if (CMAKE_TOOLCHAIN_FILE) endif (ANDROID) set(EMBED_READLINE ON) set(EMBED_BZIP2 ON) + set(EMBED_LZ4 ON) endif (CMAKE_TOOLCHAIN_FILE) -if (EMBED_READLINE OR EMBED_BZIP2) +if (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4) include(ExternalProject) -endif (EMBED_READLINE OR EMBED_BZIP2) +endif (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4) if (NOT SKIPREADLINE EQUAL 1) if (APPLE) @@ -163,6 +164,7 @@ if (NOT SKIPJANSSONSYSTEM EQUAL 1) endif (NOT SKIPJANSSONSYSTEM EQUAL 1) if(EMBED_BZIP2) + cmake_policy(SET CMP0114 NEW) set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2) ExternalProject_Add(bzip2 GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2 @@ -183,8 +185,29 @@ else(EMBED_BZIP2) find_package (BZip2 REQUIRED) endif(EMBED_BZIP2) -find_path(LZ4_INCLUDE_DIRS lz4frame.h) -find_library(LZ4_LIBRARIES lz4) +if(EMBED_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) set(LZ4_FOUND ON) @@ -501,16 +524,24 @@ else (SKIPBT EQUAL 1) endif (BLUEZ_FOUND) endif(SKIPBT EQUAL 1) -if (EMBED_BZIP2) - message(STATUS "Bzip2 library: embedded") -else (EMBED_BZIP2) - message(STATUS "Bzip2 library: system library found") -endif (EMBED_BZIP2) +if (BZIP2_FOUND) + if (EMBED_BZIP2) + message(STATUS "Bzip2 library: embedded") + else (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) - 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) - 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) if (SKIPJANSSONSYSTEM EQUAL 1) @@ -611,6 +642,9 @@ endif (EMBED_READLINE) if (EMBED_BZIP2) add_dependencies(pm3rrg_rdv4 bzip2) endif (EMBED_BZIP2) +if (EMBED_LZ4) + add_dependencies(pm3rrg_rdv4 lz4) +endif (EMBED_LZ4) if (MINGW) # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)