1 #-----------------------------------------------------------------------------
2 # Copyright (C) Jonathan Westhues, Mar 2006
3 # Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # See LICENSE.txt for the text of the license.
16 #-----------------------------------------------------------------------------
20 # cmake .. (see below for options)
21 # make (VERBOSE=1 if needed)
25 # cmake -G"MSYS Makefiles" ..
26 # On Proxspace 3.3 or less, you need to install cmake:
27 # pacman -S mingw-w64-x86_64-cmake
28 # /mingw64/bin/cmake -G"MSYS Makefiles" ..
30 # Android cross-compilation: (ANDROID_ABI=arm64-v8a for a 64b version)
32 # -DCMAKE_TOOLCHAIN_FILE=<path-to-your-android-ndk>/build/cmake/android.toolchain.cmake \
33 # -DANDROID_ABI=armeabi-v7a \
34 # -DANDROID_NATIVE_API_LEVEL=android-19 \
35 # -DSKIPBT=1 -DSKIPPYTHON=1 -DSKIPPTHREAD=1 ..
37 message(STATUS "CMake ${CMAKE_VERSION}")
38 cmake_minimum_required(VERSION 3.10)
40 SET (PM3_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
42 if(CMAKE_VERSION VERSION_LESS "3.7.0")
43 set(CMAKE_INCLUDE_CURRENT_DIR ON)
46 find_package(PkgConfig)
48 if (NOT SKIPQT EQUAL 1)
50 if(APPLE AND EXISTS /usr/local/opt/qt5)
51 # Homebrew installs Qt5 (up to at least 5.11.0) in
52 # /usr/local/opt/qt5. Ensure that it can be found by CMake
53 # since it is not in the default /usr/local prefix.
54 # Add it to PATHS so that it doesn't override the
55 # CMAKE_PREFIX_PATH environment variable.
56 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
57 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
58 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
59 endif(APPLE AND EXISTS /usr/local/opt/qt5)
61 if(APPLE AND EXISTS /opt/homebrew/opt/qt@5)
62 # Homebrew on Apple Silicon installs Qt5 in
63 # /opt/homebrew/opt/qt@5. Ensure that it can be found by CMake
64 # since it is not in the default /usr/local prefix.
65 # Add it to PATHS so that it doesn't override the
66 # CMAKE_PREFIX_PATH environment variable.
67 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
68 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
69 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /opt/homebrew/opt/qt@5)
70 endif(APPLE AND EXISTS /opt/homebrew/opt/qt@5)
77 foreach(_qt_package IN LISTS QT_PACKAGELIST)
78 find_package(${_qt_package} QUIET ${QT_FIND_PACKAGE_OPTIONS})
79 set(Qt5_LIBRARIES ${${_qt_package}_LIBRARIES} ${Qt5_LIBRARIES})
80 if(NOT ${_qt_package}_FOUND)
82 endif(NOT ${_qt_package}_FOUND)
84 endif (NOT SKIPQT EQUAL 1)
86 if (NOT SKIPBT EQUAL 1)
87 pkg_search_module(BLUEZ QUIET bluez)
88 endif (NOT SKIPBT EQUAL 1)
90 if (NOT SKIPPYTHON EQUAL 1)
91 pkg_search_module(PYTHON3 QUIET python3)
92 pkg_search_module(PYTHON3EMBED QUIET python3-embed)
93 endif (NOT SKIPPYTHON EQUAL 1)
95 # If cross-compiled, we need to init source and build.
96 if (CMAKE_TOOLCHAIN_FILE)
98 set(CFLAGS_EXTERNAL_LIB "CFLAGS=--target=${CMAKE_C_COMPILER_TARGET} -w")
100 set(EMBED_READLINE ON)
104 endif (CMAKE_TOOLCHAIN_FILE)
106 if (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4 OR EMBED_GD)
107 include(ExternalProject)
108 endif (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4 OR EMBED_GD)
110 if (NOT SKIPREADLINE EQUAL 1)
112 find_path(READLINE_INCLUDE_DIRS readline/readline.h /usr/local/opt/readline/include /opt/local/include /opt/include /usr/local/include /usr/include /opt/homebrew/opt/readline/include NO_DEFAULT_PATH)
113 find_library(READLINE_LIBRARIES readline /usr/local/opt/readline/lib /opt/local/lib /opt/lib /usr/local/lib /usr/lib /opt/homebrew/opt/readline/lib NO_DEFAULT_PATH)
116 ExternalProject_Add(ncurses
117 URL http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
119 DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/ncurses
120 CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm --disable-database --with-fallbacks=ansi-generic,ansi-mini,color_xterm,dtterm,dumb,Eterm,Eterm-256color,Eterm-88color,eterm-color,gnome,gnome-256color,guru,hurd,iTerm.app,konsole,konsole-16color,konsole-256color,konsole-base,konsole-linux,konsole-solaris,konsole-vt100,kterm,kterm-color,linux,linux-16color,linux-basic,mac,mlterm,mlterm-256color,mrxvt,mrxvt-256color,mterm,mterm-ansi,mvterm,nsterm,nsterm-16color,nsterm-256color,pty,putty,putty-256color,putty-vt100,rxvt,rxvt-16color,rxvt-256color,rxvt-88color,rxvt-basic,rxvt-color,screen,screen-16color,screen-256color,simpleterm,st-16color,st-256color,st52,st52-color,stv52,tt,tt52,unknown,vt100,vt102,vte,vte-256color,xterm,xterm-16color,xterm-256color,xterm-88color,xterm-basic,xterm-bold,xterm-color,xterm-utf8,xterm-vt220,xterm-vt52,xterm1,xtermc,xtermm --enable-termcap --without-ada --without-debug --without-dlsym --without-gpm --without-develop --without-tests --without-cxx-binding --with-termlib
122 BUILD_COMMAND make libs
126 ExternalProject_Add_StepTargets(ncurses configure build install)
128 ExternalProject_Add(readline
129 URL https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz
131 DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/readline
132 CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} --host=arm --enable-static
138 ExternalProject_Add_StepTargets(readline configure build install)
139 set(READLINE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/)
140 set(READLINE_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/readline/libreadline.a ${CMAKE_CURRENT_BINARY_DIR}/deps/ncurses/src/ncurses/lib/libtinfo.a)
141 else (EMBED_READLINE)
142 find_path(READLINE_INCLUDE_DIRS readline/readline.h)
143 find_library(READLINE_LIBRARIES readline)
144 endif (EMBED_READLINE)
145 if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
146 set(READLINE_FOUND ON)
147 endif (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
148 else (NOT SKIPREADLINE EQUAL 1)
149 if (NOT SKIPLINENOISE EQUAL 1)
150 if (EXISTS ${PM3_ROOT}/client/deps/linenoise/)
151 set(LINENOISE_LOCAL_FOUND ON)
152 endif (EXISTS ${PM3_ROOT}/client/deps/linenoise/)
153 endif (NOT SKIPLINENOISE EQUAL 1)
154 endif (NOT SKIPREADLINE EQUAL 1)
156 if (NOT SKIPJANSSONSYSTEM EQUAL 1)
157 pkg_check_modules(PC_JANSSON QUIET jansson)
158 find_path(JANSSON_INCLUDE_DIRS
160 HINTS ${PC_JANSSON_INCLUDEDIR} ${PC_JANSSON_INCLUDE_DIRS})
161 find_library(JANSSON_LIBRARIES
162 NAMES jansson libjansson
163 HINTS ${PC_JANSSON_LIBDIR} ${PC_JANSSON_LIBRARY_DIRS})
164 if (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
165 set(JANSSON_FOUND ON)
166 endif (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
167 endif (NOT SKIPJANSSONSYSTEM EQUAL 1)
170 cmake_policy(SET CMP0114 NEW)
171 set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
172 # Specify SOURCE_DIR will cause some errors
173 ExternalProject_Add(bzip2
174 GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2
175 GIT_TAG platform-tools-30.0.2
177 # SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/bzip2
178 CONFIGURE_COMMAND mkdir -p ${BZIP2_BUILD_DIR} && git archive --format tar HEAD | tar -C ${BZIP2_BUILD_DIR} -x
180 BUILD_COMMAND make -C ${BZIP2_BUILD_DIR} -j4 CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LD=${CMAKE_C_COMPILER} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} ${CFLAGS_EXTERNAL_LIB} libbz2.a
184 ExternalProject_Add_StepTargets(bzip2 configure build install)
185 set(BZIP2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
186 set(BZIP2_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2/libbz2.a)
189 find_package (BZip2 REQUIRED)
193 cmake_policy(SET CMP0114 NEW)
194 set(LZ4_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4)
195 # Specify SOURCE_DIR will cause some errors
196 ExternalProject_Add(lz4
197 GIT_REPOSITORY https://android.googlesource.com/platform/external/lz4
198 GIT_TAG platform-tools-30.0.2
200 # SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/lz4
201 CONFIGURE_COMMAND mkdir -p ${LZ4_BUILD_DIR} && git archive --format tar HEAD | tar -C ${LZ4_BUILD_DIR} -x
203 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
207 ExternalProject_Add_StepTargets(lz4 configure build install)
208 set(LZ4_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4/lib)
209 set(LZ4_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4/lib/liblz4.a)
212 find_path(LZ4_INCLUDE_DIRS lz4frame.h)
213 find_library(LZ4_LIBRARIES lz4)
216 if (LZ4_INCLUDE_DIRS AND LZ4_LIBRARIES)
218 endif (LZ4_INCLUDE_DIRS AND LZ4_LIBRARIES)
220 if (NOT SKIPGD EQUAL 1)
222 cmake_policy(SET CMP0114 NEW)
223 set(GD_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/gd)
224 # Specify SOURCE_DIR will cause some errors
225 ExternalProject_Add(gd
226 URL https://github.com/libgd/libgd/releases/download/gd-2.3.3/libgd-2.3.3.tar.gz
227 URL_HASH SHA256=dd3f1f0bb016edcc0b2d082e8229c822ad1d02223511997c80461481759b1ed2
229 CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DENABLE_CPP=0 -DCMAKE_INSTALL_PREFIX=.
230 PATCH_COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/deps/gd-static.patch | patch -p1
232 ExternalProject_Add_StepTargets(gd configure build install)
233 set(GD_INCLUDE_DIRS ${GD_BUILD_DIR}/src/gd-build/include)
234 set(GD_LIBRARIES ${GD_BUILD_DIR}/src/gd-build/lib/libgd.a)
237 pkg_search_module(GD QUIET gdlib)
239 endif (NOT SKIPGD EQUAL 1)
241 if (NOT SKIPWHEREAMISYSTEM EQUAL 1)
242 find_path(WHEREAMI_INCLUDE_DIRS whereami.h)
243 find_library(WHEREAMI_LIBRARIES whereami)
244 if (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
245 set(WHEREAMI_FOUND ON)
246 endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
247 endif (NOT SKIPWHEREAMISYSTEM EQUAL 1)
249 add_subdirectory(${PM3_ROOT}/client/deps deps)
252 ${PM3_ROOT}/common/commonutil.c
253 ${PM3_ROOT}/common/util_posix.c
254 ${PM3_ROOT}/common/bucketsort.c
255 ${PM3_ROOT}/common/crapto1/crapto1.c
256 ${PM3_ROOT}/common/crapto1/crypto1.c
257 ${PM3_ROOT}/common/crc.c
258 ${PM3_ROOT}/common/crc16.c
259 ${PM3_ROOT}/common/crc32.c
260 ${PM3_ROOT}/common/crc64.c
261 ${PM3_ROOT}/common/lfdemod.c
262 ${PM3_ROOT}/common/legic_prng.c
263 ${PM3_ROOT}/common/iso15693tools.c
264 ${PM3_ROOT}/common/cardhelper.c
265 ${PM3_ROOT}/common/generator.c
266 ${PM3_ROOT}/common/bruteforce.c
267 ${PM3_ROOT}/common/hitag2/hitag2_crypto.c
268 ${PM3_ROOT}/client/src/crypto/asn1dump.c
269 ${PM3_ROOT}/client/src/crypto/asn1utils.c
270 ${PM3_ROOT}/client/src/crypto/libpcrypto.c
271 ${PM3_ROOT}/client/src/emv/test/cda_test.c
272 ${PM3_ROOT}/client/src/emv/test/crypto_test.c
273 ${PM3_ROOT}/client/src/emv/test/cryptotest.c
274 ${PM3_ROOT}/client/src/emv/test/dda_test.c
275 ${PM3_ROOT}/client/src/emv/test/sda_test.c
276 ${PM3_ROOT}/client/src/emv/cmdemv.c
277 ${PM3_ROOT}/client/src/emv/crypto.c
278 ${PM3_ROOT}/client/src/emv/crypto_polarssl.c
279 ${PM3_ROOT}/client/src/emv/dol.c
280 ${PM3_ROOT}/client/src/emv/emv_pk.c
281 ${PM3_ROOT}/client/src/emv/emv_pki.c
282 ${PM3_ROOT}/client/src/emv/emv_pki_priv.c
283 ${PM3_ROOT}/client/src/emv/emv_roca.c
284 ${PM3_ROOT}/client/src/emv/emv_tags.c
285 ${PM3_ROOT}/client/src/emv/emvcore.c
286 ${PM3_ROOT}/client/src/emv/emvjson.c
287 ${PM3_ROOT}/client/src/emv/tlv.c
288 ${PM3_ROOT}/client/src/fido/additional_ca.c
289 ${PM3_ROOT}/client/src/fido/cbortools.c
290 ${PM3_ROOT}/client/src/fido/cose.c
291 ${PM3_ROOT}/client/src/fido/fidocore.c
292 ${PM3_ROOT}/client/src/iso7816/apduinfo.c
293 ${PM3_ROOT}/client/src/iso7816/iso7816core.c
294 ${PM3_ROOT}/client/src/ksx6924/ksx6924core.c
295 ${PM3_ROOT}/client/src/cipurse/cipursecrypto.c
296 ${PM3_ROOT}/client/src/cipurse/cipursecore.c
297 ${PM3_ROOT}/client/src/cipurse/cipursetest.c
298 ${PM3_ROOT}/client/src/loclass/cipher.c
299 ${PM3_ROOT}/client/src/loclass/cipherutils.c
300 ${PM3_ROOT}/client/src/loclass/elite_crack.c
301 ${PM3_ROOT}/client/src/loclass/hash1_brute.c
302 ${PM3_ROOT}/client/src/loclass/ikeys.c
303 ${PM3_ROOT}/client/src/mifare/mad.c
304 ${PM3_ROOT}/client/src/mifare/aiddesfire.c
305 ${PM3_ROOT}/client/src/mifare/mfkey.c
306 ${PM3_ROOT}/client/src/mifare/mifare4.c
307 ${PM3_ROOT}/client/src/mifare/mifaredefault.c
308 ${PM3_ROOT}/client/src/mifare/mifarehost.c
309 ${PM3_ROOT}/client/src/mifare/gen4.c
310 ${PM3_ROOT}/client/src/nfc/ndef.c
311 ${PM3_ROOT}/client/src/mifare/lrpcrypto.c
312 ${PM3_ROOT}/client/src/mifare/desfirecrypto.c
313 ${PM3_ROOT}/client/src/mifare/desfiresecurechan.c
314 ${PM3_ROOT}/client/src/mifare/desfirecore.c
315 ${PM3_ROOT}/client/src/mifare/desfiretest.c
316 ${PM3_ROOT}/client/src/mifare/gallaghercore.c
317 ${PM3_ROOT}/client/src/uart/ringbuffer.c
318 ${PM3_ROOT}/client/src/uart/uart_common.c
319 ${PM3_ROOT}/client/src/uart/uart_posix.c
320 ${PM3_ROOT}/client/src/uart/uart_win32.c
321 ${PM3_ROOT}/client/src/ui/overlays.ui
322 ${PM3_ROOT}/client/src/ui/image.ui
323 ${PM3_ROOT}/client/src/aidsearch.c
324 ${PM3_ROOT}/client/src/atrs.c
325 ${PM3_ROOT}/client/src/cmdanalyse.c
326 ${PM3_ROOT}/client/src/cmdcrc.c
327 ${PM3_ROOT}/client/src/cmddata.c
328 ${PM3_ROOT}/client/src/cmdflashmem.c
329 ${PM3_ROOT}/client/src/cmdflashmemspiffs.c
330 ${PM3_ROOT}/client/src/cmdhf.c
331 ${PM3_ROOT}/client/src/cmdhf14a.c
332 ${PM3_ROOT}/client/src/cmdhf14b.c
333 ${PM3_ROOT}/client/src/cmdhf15.c
334 ${PM3_ROOT}/client/src/cmdhfcryptorf.c
335 ${PM3_ROOT}/client/src/cmdhfemrtd.c
336 ${PM3_ROOT}/client/src/cmdhfepa.c
337 ${PM3_ROOT}/client/src/cmdhffelica.c
338 ${PM3_ROOT}/client/src/cmdhffido.c
339 ${PM3_ROOT}/client/src/cmdhffudan.c
340 ${PM3_ROOT}/client/src/cmdhfgallagher.c
341 ${PM3_ROOT}/client/src/cmdhfcipurse.c
342 ${PM3_ROOT}/client/src/cmdhficlass.c
343 ${PM3_ROOT}/client/src/cmdhfict.c
344 ${PM3_ROOT}/client/src/cmdhfjooki.c
345 ${PM3_ROOT}/client/src/cmdhfksx6924.c
346 ${PM3_ROOT}/client/src/cmdhflegic.c
347 ${PM3_ROOT}/client/src/cmdhflist.c
348 ${PM3_ROOT}/client/src/cmdhflto.c
349 ${PM3_ROOT}/client/src/cmdhfmf.c
350 ${PM3_ROOT}/client/src/cmdhfmfdes.c
351 ${PM3_ROOT}/client/src/cmdhfmfhard.c
352 ${PM3_ROOT}/client/src/cmdhfmfp.c
353 ${PM3_ROOT}/client/src/cmdhfmfu.c
354 ${PM3_ROOT}/client/src/cmdhfntag424.c
355 ${PM3_ROOT}/client/src/cmdhfseos.c
356 ${PM3_ROOT}/client/src/cmdhfst.c
357 ${PM3_ROOT}/client/src/cmdhfst25ta.c
358 ${PM3_ROOT}/client/src/cmdhftesla.c
359 ${PM3_ROOT}/client/src/cmdhftexkom.c
360 ${PM3_ROOT}/client/src/cmdhfthinfilm.c
361 ${PM3_ROOT}/client/src/cmdhftopaz.c
362 ${PM3_ROOT}/client/src/cmdhfvas.c
363 ${PM3_ROOT}/client/src/cmdhfxerox.c
364 ${PM3_ROOT}/client/src/cmdhw.c
365 ${PM3_ROOT}/client/src/cmdlf.c
366 ${PM3_ROOT}/client/src/cmdlfawid.c
367 ${PM3_ROOT}/client/src/cmdlfcotag.c
368 ${PM3_ROOT}/client/src/cmdlfdestron.c
369 ${PM3_ROOT}/client/src/cmdlfem.c
370 ${PM3_ROOT}/client/src/cmdlfem410x.c
371 ${PM3_ROOT}/client/src/cmdlfem4x05.c
372 ${PM3_ROOT}/client/src/cmdlfem4x50.c
373 ${PM3_ROOT}/client/src/cmdlfem4x70.c
374 ${PM3_ROOT}/client/src/cmdlffdxb.c
375 ${PM3_ROOT}/client/src/cmdlfgallagher.c
376 ${PM3_ROOT}/client/src/cmdlfguard.c
377 ${PM3_ROOT}/client/src/cmdlfhid.c
378 ${PM3_ROOT}/client/src/cmdlfhitag.c
379 ${PM3_ROOT}/client/src/cmdlfhitaghts.c
380 ${PM3_ROOT}/client/src/cmdlfidteck.c
381 ${PM3_ROOT}/client/src/cmdlfindala.c
382 ${PM3_ROOT}/client/src/cmdlfio.c
383 ${PM3_ROOT}/client/src/cmdlfjablotron.c
384 ${PM3_ROOT}/client/src/cmdlfkeri.c
385 ${PM3_ROOT}/client/src/cmdlfmotorola.c
386 ${PM3_ROOT}/client/src/cmdlfnedap.c
387 ${PM3_ROOT}/client/src/cmdlfnexwatch.c
388 ${PM3_ROOT}/client/src/cmdlfnoralsy.c
389 ${PM3_ROOT}/client/src/cmdlfpac.c
390 ${PM3_ROOT}/client/src/cmdlfparadox.c
391 ${PM3_ROOT}/client/src/cmdlfpcf7931.c
392 ${PM3_ROOT}/client/src/cmdlfpresco.c
393 ${PM3_ROOT}/client/src/cmdlfpyramid.c
394 ${PM3_ROOT}/client/src/cmdlfsecurakey.c
395 ${PM3_ROOT}/client/src/cmdlft55xx.c
396 ${PM3_ROOT}/client/src/cmdlfti.c
397 ${PM3_ROOT}/client/src/cmdlfviking.c
398 ${PM3_ROOT}/client/src/cmdlfvisa2000.c
399 ${PM3_ROOT}/client/src/cmdlfzx8211.c
400 ${PM3_ROOT}/client/src/cmdmain.c
401 ${PM3_ROOT}/client/src/cmdnfc.c
402 ${PM3_ROOT}/client/src/cmdparser.c
403 ${PM3_ROOT}/client/src/cmdpiv.c
404 ${PM3_ROOT}/client/src/cmdscript.c
405 ${PM3_ROOT}/client/src/cmdsmartcard.c
406 ${PM3_ROOT}/client/src/cmdtrace.c
407 ${PM3_ROOT}/client/src/cmdusart.c
408 ${PM3_ROOT}/client/src/cmdwiegand.c
409 ${PM3_ROOT}/client/src/comms.c
410 ${PM3_ROOT}/client/src/fileutils.c
411 ${PM3_ROOT}/client/src/flash.c
412 ${PM3_ROOT}/client/src/graph.c
413 ${PM3_ROOT}/client/src/iso4217.c
414 ${PM3_ROOT}/client/src/jansson_path.c
415 ${PM3_ROOT}/client/src/preferences.c
416 ${PM3_ROOT}/client/src/pm3.c
417 ${PM3_ROOT}/client/src/pm3_binlib.c
418 ${PM3_ROOT}/client/src/pm3_bitlib.c
419 ${PM3_ROOT}/client/src/pm3line.c
420 ${PM3_ROOT}/client/src/scandir.c
421 ${PM3_ROOT}/client/src/scripting.c
422 ${PM3_ROOT}/client/src/ui.c
423 ${PM3_ROOT}/client/src/util.c
424 ${PM3_ROOT}/client/src/wiegand_formats.c
425 ${PM3_ROOT}/client/src/wiegand_formatutils.c
426 ${CMAKE_BINARY_DIR}/version_pm3.c
430 OUTPUT ${CMAKE_BINARY_DIR}/version_pm3.c
431 COMMAND ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version_pm3.c ${CMAKE_BINARY_DIR}/version_pm3.c
432 DEPENDS ${PM3_ROOT}/common/default_version_pm3.c
435 set(ADDITIONAL_SRC "")
436 set(ADDITIONAL_LNK "")
437 set(ADDITIONAL_DIRS "")
438 set(ADDITIONAL_LNKDIRS "")
439 set(X86_CPUS x86 x86_64 i686)
441 message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
444 message(STATUS "Apple device detected.")
445 set(ADDITIONAL_SRC ${PM3_ROOT}/client/src/util_darwin.h ${PM3_ROOT}/client/src/util_darwin.m ${ADDITIONAL_SRC})
447 find_library(UIKIT_LIBRARY UIKit)
448 if (NOT UIKIT_LIBRARY)
449 message(STATUS "UIKit.framework NOT found!")
451 message(STATUS "UIKit.framework found! ${UIKIT_LIBRARY}")
452 set(ADDITIONAL_LNK "-framework Foundation" "-framework UIKit")
455 find_library(APPKIT_LIBRARY AppKit)
456 if (NOT APPKIT_LIBRARY)
457 message(STATUS "AppKit.framework NOT found!")
459 message(STATUS "AppKit.framework found! ${APPKIT_LIBRARY}")
460 set(ADDITIONAL_LNK "-framework Foundation" "-framework AppKit")
464 if ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
465 set(CMAKE_AUTOMOC ON)
466 set(CMAKE_AUTORCC ON)
467 set(CMAKE_AUTOUIC ON)
469 ${PM3_ROOT}/client/src/proxgui.cpp
470 ${PM3_ROOT}/client/src/proxguiqt.cpp
473 add_definitions("-DHAVE_GUI")
474 set(ADDITIONAL_LNK ${Qt5_LIBRARIES} ${ADDITIONAL_LNK})
475 else ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
477 ${PM3_ROOT}/client/src/guidummy.cpp
479 endif ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
481 if (NOT SKIPBT EQUAL 1)
483 add_definitions("-DHAVE_BLUEZ")
484 set(ADDITIONAL_LNK ${BLUEZ_LIBRARIES} ${ADDITIONAL_LNK})
486 endif(NOT SKIPBT EQUAL 1)
489 set(ADDITIONAL_DIRS ${JANSSON_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
490 set(ADDITIONAL_LNK ${JANSSON_LIBRARIES} ${ADDITIONAL_LNK})
491 endif (JANSSON_FOUND)
493 if (NOT SKIPPYTHON EQUAL 1)
494 if (PYTHON3EMBED_FOUND)
495 add_definitions(-DHAVE_PYTHON)
496 set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
497 set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
498 set(ADDITIONAL_LNKDIRS ${PYTHON3EMBED_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
499 elseif (PYTHON3_FOUND)
500 add_definitions(-DHAVE_PYTHON)
501 set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
502 set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
503 set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
504 endif (PYTHON3EMBED_FOUND)
505 endif (NOT SKIPPYTHON EQUAL 1)
507 if (NOT SKIPREADLINE EQUAL 1)
509 add_definitions("-DHAVE_READLINE")
510 set(ADDITIONAL_DIRS ${READLINE_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
511 set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK})
512 endif (READLINE_FOUND)
513 endif(NOT SKIPREADLINE EQUAL 1)
516 set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
517 set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK})
521 set(ADDITIONAL_DIRS ${LZ4_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
522 set(ADDITIONAL_LNK ${LZ4_LIBRARIES} ${ADDITIONAL_LNK})
525 if (NOT SKIPGD EQUAL 1 AND GD_FOUND)
526 set(ADDITIONAL_DIRS ${GD_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
527 set(ADDITIONAL_LNK ${GD_LIBRARIES} ${ADDITIONAL_LNK})
528 set(ADDITIONAL_LNKDIRS ${GD_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
530 ${PM3_ROOT}/client/src/imgutils.c
531 ${PM3_ROOT}/client/src/cmdhfwaveshare.c
533 add_definitions("-DHAVE_GD")
534 endif (NOT SKIPGD EQUAL 1 AND GD_FOUND)
537 set(ADDITIONAL_DIRS ${WHEREAMI_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
538 set(ADDITIONAL_LNK ${WHEREAMI_LIBRARIES} ${ADDITIONAL_LNK})
539 endif (WHEREAMI_FOUND)
541 message(STATUS "===================================================================")
543 COMMAND sh ${PM3_ROOT}/tools/mkversion.sh --short
544 OUTPUT_VARIABLE version_pm3
546 string(STRIP ${version_pm3} version_pm3)
547 message(STATUS "Version info: ${version_pm3}")
549 message(STATUS "GUI support: skipped")
550 else (SKIPQT EQUAL 1)
552 message(STATUS "GUI support: QT5 found, enabled")
554 message(STATUS "GUI support: QT5 not found, disabled")
556 endif (SKIPQT EQUAL 1)
559 message(STATUS "native BT support: skipped")
560 else (SKIPBT EQUAL 1)
562 message(STATUS "native BT support: Bluez found, enabled")
564 message(STATUS "native BT support: Bluez not found, disabled")
566 endif(SKIPBT EQUAL 1)
570 message(STATUS "Bzip2 library: embedded")
572 message(STATUS "Bzip2 library: system library found")
575 message(SEND_ERROR "Bzip2 library: Bzip2 not found")
580 message(STATUS "LZ4 library: embedded")
582 message(STATUS "LZ4 library: system library found")
585 message(SEND_ERROR "LZ4 library: LZ4 not found")
589 message(STATUS "GD library: skipped")
592 message(STATUS "GD library: embedded")
594 message(STATUS "GD library: system library found")
596 else (SKIPGD EQUAL 1)
597 message(STATUS "GD library: GD not found, disabled")
598 endif (SKIPGD EQUAL 1)
600 if (SKIPJANSSONSYSTEM EQUAL 1)
601 message(STATUS "Jansson library: local library forced")
602 else (SKIPJANSSONSYSTEM EQUAL 1)
604 message(STATUS "Jansson library: system library found")
606 message(STATUS "Jansson library: system library not found, using local library")
607 endif (JANSSON_FOUND)
608 endif (SKIPJANSSONSYSTEM EQUAL 1)
610 if (SKIPPYTHON EQUAL 1)
611 message(STATUS "Python3 library: skipped")
612 else (SKIPPYTHON EQUAL 1)
613 if (PYTHON3EMBED_FOUND)
614 message(STATUS "Python3 library: Python3 embed found, enabled")
615 elseif (PYTHON3_FOUND)
616 message(STATUS "Python3 library: Python3 found, enabled")
617 else (PYTHON3EMBED_FOUND)
618 message(STATUS "Python3 library: Python3 not found, disabled")
619 endif (PYTHON3EMBED_FOUND)
620 endif(SKIPPYTHON EQUAL 1)
622 if (SKIPREADLINE EQUAL 1)
623 message(STATUS "Readline library: skipped")
624 else (SKIPREADLINE EQUAL 1)
627 message(STATUS "Readline library: embedded")
628 else (EMBED_READLINE)
629 message(STATUS "Readline library: system library found")
630 endif (EMBED_READLINE)
631 else (READLINE_FOUND)
632 message(STATUS "Readline library: Readline not found, disabled")
633 endif (READLINE_FOUND)
634 endif(SKIPREADLINE EQUAL 1)
636 if (NOT READLINE_FOUND)
637 if (SKIPLINENOISE EQUAL 1)
638 message(STATUS "Linenoise library: skipped")
639 else (SKIPLINENOISE EQUAL 1)
640 if (LINENOISE_LOCAL_FOUND)
641 message(STATUS "Linenoise library: enabled")
642 else (LINENOISE_LOCAL_FOUND)
643 message(STATUS "Linenoise library: Linenoise not found, disabled")
644 endif (LINENOISE_LOCAL_FOUND)
645 endif (SKIPLINENOISE EQUAL 1)
646 endif (NOT READLINE_FOUND)
648 if (SKIPWHEREAMISYSTEM EQUAL 1)
649 message(STATUS "Whereami library: local library forced")
650 else (SKIPWHEREAMISYSTEM EQUAL 1)
652 message(STATUS "Whereami library: system library found")
653 else (WHEREAMI_FOUND)
654 message(STATUS "Whereami library: system library not found, using local library")
655 endif (WHEREAMI_FOUND)
656 endif (SKIPWHEREAMISYSTEM EQUAL 1)
659 if (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
661 ${PM3_ROOT}/client/src/pm3_luawrap.c
663 add_definitions(-DHAVE_LUA_SWIG)
664 message(STATUS "Lua SWIG: wrapper found")
665 endif (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
668 if (NOT SKIPPYTHON EQUAL 1)
669 if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
670 if (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
672 ${PM3_ROOT}/client/src/pm3_pywrap.c
674 add_definitions(-DHAVE_PYTHON_SWIG)
675 message(STATUS "Python SWIG: wrapper found")
676 endif (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
677 endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
678 endif (NOT SKIPPYTHON EQUAL 1)
679 message(STATUS "===================================================================")
681 add_definitions(-DHAVE_SNPRINTF)
683 add_library(pm3rrg_rdv4 SHARED
684 ${PM3_ROOT}/client/src/proxmark3.c
689 target_compile_definitions(pm3rrg_rdv4 PRIVATE LIBPM3)
691 target_compile_options(pm3rrg_rdv4 PUBLIC -Wall -Werror -O3)
693 if (NOT SKIPREADLINE EQUAL 1)
694 add_dependencies(pm3rrg_rdv4 ncurses readline)
695 endif (NOT SKIPREADLINE EQUAL 1)
696 endif (EMBED_READLINE)
698 add_dependencies(pm3rrg_rdv4 bzip2)
701 add_dependencies(pm3rrg_rdv4 lz4)
705 # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
706 # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
707 # FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
708 # but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
709 target_compile_definitions(pm3rrg_rdv4 PRIVATE _ISOC99_SOURCE)
711 set(CMAKE_C_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_C_FLAGS}")
712 set(CMAKE_CXX_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_CXX_FLAGS}")
715 set(ADDITIONAL_LNK ws2_32 ${ADDITIONAL_LNK})
718 # GCC 10 has issues with false positives on stringop-overflow,
719 # let's disable them for now (cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92955, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335)
720 # beware these flags didn't exist for GCC < 7
721 if(CMAKE_COMPILER_IS_GNUCXX)
722 execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
723 if (GCC_VERSION VERSION_GREATER 10.0 OR GCC_VERSION VERSION_EQUAL 10.0)
724 set(CMAKE_C_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_C_FLAGS}")
725 set(CMAKE_CXX_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_CXX_FLAGS}")
727 endif(CMAKE_COMPILER_IS_GNUCXX)
729 target_include_directories(pm3rrg_rdv4 PRIVATE
731 ${PM3_ROOT}/common_fpga
733 ${PM3_ROOT}/client/src
734 ${PM3_ROOT}/client/include
739 # required for Raspberry Pi, but breaks with clang (OSX). Need to be at the end of the linker line.
740 set(ADDITIONAL_LNK ${ADDITIONAL_LNK} -Wl,--as-needed -latomic -Wl,--no-as-needed)
742 #set_property(TARGET proxmark3 PROPERTY LINK_FLAGS "-Wl,-undefined dynamic_lookup")
743 set(ADDITIONAL_LNK ${ADDITIONAL_LNK} -Wl,-undefined,dynamic_lookup)
746 if (NOT JANSSON_FOUND)
747 set(ADDITIONAL_LNK pm3rrg_rdv4_jansson ${ADDITIONAL_LNK})
748 endif (NOT JANSSON_FOUND)
750 if (NOT READLINE_FOUND)
751 if (LINENOISE_LOCAL_FOUND)
752 add_definitions("-DHAVE_LINENOISE")
753 set(ADDITIONAL_LNK pm3rrg_rdv4_linenoise ${ADDITIONAL_LNK})
754 endif (LINENOISE_LOCAL_FOUND)
755 endif (NOT READLINE_FOUND)
757 if (NOT WHEREAMI_FOUND)
758 set(ADDITIONAL_LNK pm3rrg_rdv4_whereami ${ADDITIONAL_LNK})
759 endif (NOT WHEREAMI_FOUND)
761 target_link_libraries(pm3rrg_rdv4 PRIVATE
764 pm3rrg_rdv4_cliparser
769 pm3rrg_rdv4_hardnested
773 if (NOT SKIPPTHREAD EQUAL 1)
774 target_link_libraries(pm3rrg_rdv4 PRIVATE pthread)
775 endif (NOT SKIPPTHREAD EQUAL 1)
777 if (NOT SKIPPYTHON EQUAL 1)
778 # OSX have a hard time compiling python3 dependency with older cmake.
779 if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
780 if (CMAKE_VERSION VERSION_LESS 3.13)
781 message( SEND_ERROR "Your CMAKE version is too old for Apple platform, please update to a version >=3.13" )
782 endif (CMAKE_VERSION VERSION_LESS 3.13)
783 endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
784 endif (NOT SKIPPYTHON EQUAL 1)
786 target_link_directories(pm3rrg_rdv4 PRIVATE ${ADDITIONAL_LNKDIRS})