1 #-----------------------------------------------------------------------------
2 # Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # See LICENSE.txt for the text of the license.
15 #-----------------------------------------------------------------------------
19 # cmake .. (see below for options)
20 # make (VERBOSE=1 if needed)
24 # cmake -G"MSYS Makefiles" ..
25 # On Proxspace 3.3 or less, you need to install cmake:
26 # pacman -S mingw-w64-x86_64-cmake
27 # /mingw64/bin/cmake -G"MSYS Makefiles" ..
29 # Android cross-compilation: (ANDROID_ABI=arm64-v8a for a 64b version)
31 # -DCMAKE_TOOLCHAIN_FILE=<path-to-your-android-ndk>/build/cmake/android.toolchain.cmake \
32 # -DANDROID_ABI=armeabi-v7a \
33 # -DANDROID_NATIVE_API_LEVEL=android-19 \
34 # -DSKIPBT=1 -DSKIPPYTHON=1 -DSKIPPTHREAD=1 ..
36 message(STATUS "CMake ${CMAKE_VERSION}")
37 cmake_minimum_required(VERSION 3.10)
39 SET (PM3_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
41 if(CMAKE_VERSION VERSION_LESS "3.7.0")
42 set(CMAKE_INCLUDE_CURRENT_DIR ON)
45 find_package(PkgConfig)
47 if (NOT SKIPQT EQUAL 1)
49 if(APPLE AND EXISTS /usr/local/opt/qt5)
50 # Homebrew installs Qt5 (up to at least 5.11.0) in
51 # /usr/local/opt/qt5. Ensure that it can be found by CMake
52 # since it is not in the default /usr/local prefix.
53 # Add it to PATHS so that it doesn't override the
54 # CMAKE_PREFIX_PATH environment variable.
55 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
56 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
57 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
58 endif(APPLE AND EXISTS /usr/local/opt/qt5)
60 if(APPLE AND EXISTS /opt/homebrew/opt/qt@5)
61 # Homebrew on Apple Silicon installs Qt5 in
62 # /opt/homebrew/opt/qt@5. Ensure that it can be found by CMake
63 # since it is not in the default /usr/local prefix.
64 # Add it to PATHS so that it doesn't override the
65 # CMAKE_PREFIX_PATH environment variable.
66 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
67 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
68 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /opt/homebrew/opt/qt@5)
69 endif(APPLE AND EXISTS /opt/homebrew/opt/qt@5)
76 foreach(_qt_package IN LISTS QT_PACKAGELIST)
77 find_package(${_qt_package} QUIET ${QT_FIND_PACKAGE_OPTIONS})
78 set(Qt5_LIBRARIES ${${_qt_package}_LIBRARIES} ${Qt5_LIBRARIES})
79 if(NOT ${_qt_package}_FOUND)
81 endif(NOT ${_qt_package}_FOUND)
83 endif (NOT SKIPQT EQUAL 1)
85 if (NOT SKIPBT EQUAL 1)
86 pkg_search_module(BLUEZ QUIET bluez)
87 endif (NOT SKIPBT EQUAL 1)
89 if (NOT SKIPPYTHON EQUAL 1)
90 pkg_search_module(PYTHON3 QUIET python3)
91 pkg_search_module(PYTHON3EMBED QUIET python3-embed)
92 endif (NOT SKIPPYTHON EQUAL 1)
94 # If cross-compiled, we need to init source and build.
95 if (CMAKE_TOOLCHAIN_FILE)
97 set(CFLAGS_EXTERNAL_LIB "CFLAGS=--target=${CMAKE_C_COMPILER_TARGET} -w")
99 set(EMBED_READLINE ON)
103 endif (CMAKE_TOOLCHAIN_FILE)
105 if (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4 OR EMBED_GD)
106 include(ExternalProject)
107 endif (EMBED_READLINE OR EMBED_BZIP2 OR EMBED_LZ4 OR EMBED_GD)
109 if (NOT SKIPREADLINE EQUAL 1)
111 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)
112 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)
115 ExternalProject_Add(ncurses
116 URL http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
118 DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/ncurses
119 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
121 BUILD_COMMAND make libs
125 ExternalProject_Add_StepTargets(ncurses configure build install)
127 ExternalProject_Add(readline
128 URL https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz
130 DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/readline
131 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
137 ExternalProject_Add_StepTargets(readline configure build install)
138 set(READLINE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/)
139 set(READLINE_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/readline/libreadline.a ${CMAKE_CURRENT_BINARY_DIR}/deps/ncurses/src/ncurses/lib/libtinfo.a)
140 else (EMBED_READLINE)
141 find_path(READLINE_INCLUDE_DIRS readline/readline.h)
142 find_library(READLINE_LIBRARIES readline)
143 endif (EMBED_READLINE)
144 if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
145 set(READLINE_FOUND ON)
146 endif (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
147 else (NOT SKIPREADLINE EQUAL 1)
148 if (NOT SKIPLINENOISE EQUAL 1)
149 if (EXISTS ${PM3_ROOT}/client/deps/linenoise/)
150 set(LINENOISE_LOCAL_FOUND ON)
151 endif (EXISTS ${PM3_ROOT}/client/deps/linenoise/)
152 endif (NOT SKIPLINENOISE EQUAL 1)
153 endif (NOT SKIPREADLINE EQUAL 1)
155 if (NOT SKIPJANSSONSYSTEM EQUAL 1)
156 pkg_check_modules(PC_JANSSON QUIET jansson)
157 find_path(JANSSON_INCLUDE_DIRS
159 HINTS ${PC_JANSSON_INCLUDEDIR} ${PC_JANSSON_INCLUDE_DIRS})
160 find_library(JANSSON_LIBRARIES
161 NAMES jansson libjansson
162 HINTS ${PC_JANSSON_LIBDIR} ${PC_JANSSON_LIBRARY_DIRS})
163 if (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
164 set(JANSSON_FOUND ON)
165 endif (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
166 endif (NOT SKIPJANSSONSYSTEM EQUAL 1)
169 cmake_policy(SET CMP0114 NEW)
170 set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
171 # Specify SOURCE_DIR will cause some errors
172 ExternalProject_Add(bzip2
173 GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2
174 GIT_TAG platform-tools-30.0.2
176 # SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/bzip2
177 CONFIGURE_COMMAND mkdir -p ${BZIP2_BUILD_DIR} && git archive --format tar HEAD | tar -C ${BZIP2_BUILD_DIR} -x
179 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
183 ExternalProject_Add_StepTargets(bzip2 configure build install)
184 set(BZIP2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
185 set(BZIP2_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2/libbz2.a)
188 find_package (BZip2 REQUIRED)
192 cmake_policy(SET CMP0114 NEW)
193 set(LZ4_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4)
194 # Specify SOURCE_DIR will cause some errors
195 ExternalProject_Add(lz4
196 GIT_REPOSITORY https://android.googlesource.com/platform/external/lz4
197 GIT_TAG platform-tools-30.0.2
199 # SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/lz4
200 CONFIGURE_COMMAND mkdir -p ${LZ4_BUILD_DIR} && git archive --format tar HEAD | tar -C ${LZ4_BUILD_DIR} -x
202 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
206 ExternalProject_Add_StepTargets(lz4 configure build install)
207 set(LZ4_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4/lib)
208 set(LZ4_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/lz4/src/lz4/lib/liblz4.a)
211 find_path(LZ4_INCLUDE_DIRS lz4frame.h)
212 find_library(LZ4_LIBRARIES lz4)
215 if (LZ4_INCLUDE_DIRS AND LZ4_LIBRARIES)
217 endif (LZ4_INCLUDE_DIRS AND LZ4_LIBRARIES)
219 if (NOT SKIPGD EQUAL 1)
221 cmake_policy(SET CMP0114 NEW)
222 set(GD_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/gd)
223 # Specify SOURCE_DIR will cause some errors
224 ExternalProject_Add(gd
225 URL https://github.com/libgd/libgd/releases/download/gd-2.3.3/libgd-2.3.3.tar.gz
226 URL_HASH SHA256=dd3f1f0bb016edcc0b2d082e8229c822ad1d02223511997c80461481759b1ed2
228 CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DENABLE_CPP=0 -DCMAKE_INSTALL_PREFIX=.
229 PATCH_COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/deps/gd-static.patch | patch -p1
231 ExternalProject_Add_StepTargets(gd configure build install)
232 set(GD_INCLUDE_DIRS ${GD_BUILD_DIR}/src/gd-build/include)
233 set(GD_LIBRARIES ${GD_BUILD_DIR}/src/gd-build/lib/libgd.a)
236 pkg_search_module(GD QUIET gdlib)
238 endif (NOT SKIPGD EQUAL 1)
240 if (NOT SKIPWHEREAMISYSTEM EQUAL 1)
241 find_path(WHEREAMI_INCLUDE_DIRS whereami.h)
242 find_library(WHEREAMI_LIBRARIES whereami)
243 if (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
244 set(WHEREAMI_FOUND ON)
245 endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
246 endif (NOT SKIPWHEREAMISYSTEM EQUAL 1)
248 add_subdirectory(${PM3_ROOT}/client/deps deps)
251 ${PM3_ROOT}/common/commonutil.c
252 ${PM3_ROOT}/common/util_posix.c
253 ${PM3_ROOT}/common/bucketsort.c
254 ${PM3_ROOT}/common/crapto1/crapto1.c
255 ${PM3_ROOT}/common/crapto1/crypto1.c
256 ${PM3_ROOT}/common/crc.c
257 ${PM3_ROOT}/common/crc16.c
258 ${PM3_ROOT}/common/crc32.c
259 ${PM3_ROOT}/common/crc64.c
260 ${PM3_ROOT}/common/lfdemod.c
261 ${PM3_ROOT}/common/legic_prng.c
262 ${PM3_ROOT}/common/iso15693tools.c
263 ${PM3_ROOT}/common/cardhelper.c
264 ${PM3_ROOT}/common/generator.c
265 ${PM3_ROOT}/common/bruteforce.c
266 ${PM3_ROOT}/common/hitag2/hitag2_crypto.c
267 ${PM3_ROOT}/client/src/crypto/asn1dump.c
268 ${PM3_ROOT}/client/src/crypto/asn1utils.c
269 ${PM3_ROOT}/client/src/crypto/libpcrypto.c
270 ${PM3_ROOT}/client/src/emv/test/cda_test.c
271 ${PM3_ROOT}/client/src/emv/test/crypto_test.c
272 ${PM3_ROOT}/client/src/emv/test/cryptotest.c
273 ${PM3_ROOT}/client/src/emv/test/dda_test.c
274 ${PM3_ROOT}/client/src/emv/test/sda_test.c
275 ${PM3_ROOT}/client/src/emv/cmdemv.c
276 ${PM3_ROOT}/client/src/emv/crypto.c
277 ${PM3_ROOT}/client/src/emv/crypto_polarssl.c
278 ${PM3_ROOT}/client/src/emv/dol.c
279 ${PM3_ROOT}/client/src/emv/emv_pk.c
280 ${PM3_ROOT}/client/src/emv/emv_pki.c
281 ${PM3_ROOT}/client/src/emv/emv_pki_priv.c
282 ${PM3_ROOT}/client/src/emv/emv_roca.c
283 ${PM3_ROOT}/client/src/emv/emv_tags.c
284 ${PM3_ROOT}/client/src/emv/emvcore.c
285 ${PM3_ROOT}/client/src/emv/emvjson.c
286 ${PM3_ROOT}/client/src/emv/tlv.c
287 ${PM3_ROOT}/client/src/fido/additional_ca.c
288 ${PM3_ROOT}/client/src/fido/cbortools.c
289 ${PM3_ROOT}/client/src/fido/cose.c
290 ${PM3_ROOT}/client/src/fido/fidocore.c
291 ${PM3_ROOT}/client/src/iso7816/apduinfo.c
292 ${PM3_ROOT}/client/src/iso7816/iso7816core.c
293 ${PM3_ROOT}/client/src/ksx6924/ksx6924core.c
294 ${PM3_ROOT}/client/src/cipurse/cipursecrypto.c
295 ${PM3_ROOT}/client/src/cipurse/cipursecore.c
296 ${PM3_ROOT}/client/src/cipurse/cipursetest.c
297 ${PM3_ROOT}/client/src/loclass/cipher.c
298 ${PM3_ROOT}/client/src/loclass/cipherutils.c
299 ${PM3_ROOT}/client/src/loclass/elite_crack.c
300 ${PM3_ROOT}/client/src/loclass/hash1_brute.c
301 ${PM3_ROOT}/client/src/loclass/ikeys.c
302 ${PM3_ROOT}/client/src/mifare/mad.c
303 ${PM3_ROOT}/client/src/mifare/aiddesfire.c
304 ${PM3_ROOT}/client/src/mifare/mfkey.c
305 ${PM3_ROOT}/client/src/mifare/mifare4.c
306 ${PM3_ROOT}/client/src/mifare/mifaredefault.c
307 ${PM3_ROOT}/client/src/mifare/mifarehost.c
308 ${PM3_ROOT}/client/src/mifare/gen4.c
309 ${PM3_ROOT}/client/src/nfc/ndef.c
310 ${PM3_ROOT}/client/src/mifare/lrpcrypto.c
311 ${PM3_ROOT}/client/src/mifare/desfirecrypto.c
312 ${PM3_ROOT}/client/src/mifare/desfiresecurechan.c
313 ${PM3_ROOT}/client/src/mifare/desfirecore.c
314 ${PM3_ROOT}/client/src/mifare/desfiretest.c
315 ${PM3_ROOT}/client/src/mifare/gallaghercore.c
316 ${PM3_ROOT}/client/src/uart/ringbuffer.c
317 ${PM3_ROOT}/client/src/uart/uart_common.c
318 ${PM3_ROOT}/client/src/uart/uart_posix.c
319 ${PM3_ROOT}/client/src/uart/uart_win32.c
320 ${PM3_ROOT}/client/src/ui/overlays.ui
321 ${PM3_ROOT}/client/src/ui/image.ui
322 ${PM3_ROOT}/client/src/aidsearch.c
323 ${PM3_ROOT}/client/src/atrs.c
324 ${PM3_ROOT}/client/src/cmdanalyse.c
325 ${PM3_ROOT}/client/src/cmdcrc.c
326 ${PM3_ROOT}/client/src/cmddata.c
327 ${PM3_ROOT}/client/src/cmdflashmem.c
328 ${PM3_ROOT}/client/src/cmdflashmemspiffs.c
329 ${PM3_ROOT}/client/src/cmdhf.c
330 ${PM3_ROOT}/client/src/cmdhf14a.c
331 ${PM3_ROOT}/client/src/cmdhf14b.c
332 ${PM3_ROOT}/client/src/cmdhf15.c
333 ${PM3_ROOT}/client/src/cmdhfcryptorf.c
334 ${PM3_ROOT}/client/src/cmdhfemrtd.c
335 ${PM3_ROOT}/client/src/cmdhfepa.c
336 ${PM3_ROOT}/client/src/cmdhffelica.c
337 ${PM3_ROOT}/client/src/cmdhffido.c
338 ${PM3_ROOT}/client/src/cmdhffudan.c
339 ${PM3_ROOT}/client/src/cmdhfgallagher.c
340 ${PM3_ROOT}/client/src/cmdhfcipurse.c
341 ${PM3_ROOT}/client/src/cmdhficlass.c
342 ${PM3_ROOT}/client/src/cmdhfict.c
343 ${PM3_ROOT}/client/src/cmdhfjooki.c
344 ${PM3_ROOT}/client/src/cmdhfksx6924.c
345 ${PM3_ROOT}/client/src/cmdhflegic.c
346 ${PM3_ROOT}/client/src/cmdhflist.c
347 ${PM3_ROOT}/client/src/cmdhflto.c
348 ${PM3_ROOT}/client/src/cmdhfmf.c
349 ${PM3_ROOT}/client/src/cmdhfmfdes.c
350 ${PM3_ROOT}/client/src/cmdhfmfhard.c
351 ${PM3_ROOT}/client/src/cmdhfmfp.c
352 ${PM3_ROOT}/client/src/cmdhfmfu.c
353 ${PM3_ROOT}/client/src/cmdhfntag424.c
354 ${PM3_ROOT}/client/src/cmdhfseos.c
355 ${PM3_ROOT}/client/src/cmdhfst.c
356 ${PM3_ROOT}/client/src/cmdhfst25ta.c
357 ${PM3_ROOT}/client/src/cmdhftesla.c
358 ${PM3_ROOT}/client/src/cmdhftexkom.c
359 ${PM3_ROOT}/client/src/cmdhfthinfilm.c
360 ${PM3_ROOT}/client/src/cmdhftopaz.c
361 ${PM3_ROOT}/client/src/cmdhfvas.c
362 ${PM3_ROOT}/client/src/cmdhfxerox.c
363 ${PM3_ROOT}/client/src/cmdhw.c
364 ${PM3_ROOT}/client/src/cmdlf.c
365 ${PM3_ROOT}/client/src/cmdlfawid.c
366 ${PM3_ROOT}/client/src/cmdlfcotag.c
367 ${PM3_ROOT}/client/src/cmdlfdestron.c
368 ${PM3_ROOT}/client/src/cmdlfem.c
369 ${PM3_ROOT}/client/src/cmdlfem410x.c
370 ${PM3_ROOT}/client/src/cmdlfem4x05.c
371 ${PM3_ROOT}/client/src/cmdlfem4x50.c
372 ${PM3_ROOT}/client/src/cmdlfem4x70.c
373 ${PM3_ROOT}/client/src/cmdlffdxb.c
374 ${PM3_ROOT}/client/src/cmdlfgallagher.c
375 ${PM3_ROOT}/client/src/cmdlfguard.c
376 ${PM3_ROOT}/client/src/cmdlfhid.c
377 ${PM3_ROOT}/client/src/cmdlfhitag.c
378 ${PM3_ROOT}/client/src/cmdlfhitaghts.c
379 ${PM3_ROOT}/client/src/cmdlfidteck.c
380 ${PM3_ROOT}/client/src/cmdlfindala.c
381 ${PM3_ROOT}/client/src/cmdlfio.c
382 ${PM3_ROOT}/client/src/cmdlfjablotron.c
383 ${PM3_ROOT}/client/src/cmdlfkeri.c
384 ${PM3_ROOT}/client/src/cmdlfmotorola.c
385 ${PM3_ROOT}/client/src/cmdlfnedap.c
386 ${PM3_ROOT}/client/src/cmdlfnexwatch.c
387 ${PM3_ROOT}/client/src/cmdlfnoralsy.c
388 ${PM3_ROOT}/client/src/cmdlfpac.c
389 ${PM3_ROOT}/client/src/cmdlfparadox.c
390 ${PM3_ROOT}/client/src/cmdlfpcf7931.c
391 ${PM3_ROOT}/client/src/cmdlfpresco.c
392 ${PM3_ROOT}/client/src/cmdlfpyramid.c
393 ${PM3_ROOT}/client/src/cmdlfsecurakey.c
394 ${PM3_ROOT}/client/src/cmdlft55xx.c
395 ${PM3_ROOT}/client/src/cmdlfti.c
396 ${PM3_ROOT}/client/src/cmdlfviking.c
397 ${PM3_ROOT}/client/src/cmdlfvisa2000.c
398 ${PM3_ROOT}/client/src/cmdlfzx8211.c
399 ${PM3_ROOT}/client/src/cmdmain.c
400 ${PM3_ROOT}/client/src/cmdnfc.c
401 ${PM3_ROOT}/client/src/cmdparser.c
402 ${PM3_ROOT}/client/src/cmdpiv.c
403 ${PM3_ROOT}/client/src/cmdscript.c
404 ${PM3_ROOT}/client/src/cmdsmartcard.c
405 ${PM3_ROOT}/client/src/cmdtrace.c
406 ${PM3_ROOT}/client/src/cmdusart.c
407 ${PM3_ROOT}/client/src/cmdwiegand.c
408 ${PM3_ROOT}/client/src/comms.c
409 ${PM3_ROOT}/client/src/fileutils.c
410 ${PM3_ROOT}/client/src/flash.c
411 ${PM3_ROOT}/client/src/graph.c
412 ${PM3_ROOT}/client/src/iso4217.c
413 ${PM3_ROOT}/client/src/jansson_path.c
414 ${PM3_ROOT}/client/src/preferences.c
415 ${PM3_ROOT}/client/src/pm3.c
416 ${PM3_ROOT}/client/src/pm3_binlib.c
417 ${PM3_ROOT}/client/src/pm3_bitlib.c
418 ${PM3_ROOT}/client/src/pm3line.c
419 ${PM3_ROOT}/client/src/scandir.c
420 ${PM3_ROOT}/client/src/scripting.c
421 ${PM3_ROOT}/client/src/ui.c
422 ${PM3_ROOT}/client/src/util.c
423 ${PM3_ROOT}/client/src/wiegand_formats.c
424 ${PM3_ROOT}/client/src/wiegand_formatutils.c
425 ${CMAKE_BINARY_DIR}/version_pm3.c
429 OUTPUT ${CMAKE_BINARY_DIR}/version_pm3.c
430 COMMAND sh ${PM3_ROOT}/tools/mkversion.sh ${CMAKE_BINARY_DIR}/version_pm3.c || ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version_pm3.c ${CMAKE_BINARY_DIR}/version_pm3.c
431 DEPENDS ${PM3_ROOT}/common/default_version_pm3.c
434 set(ADDITIONAL_SRC "")
435 set(ADDITIONAL_LNK "")
436 set(ADDITIONAL_DIRS "")
437 set(ADDITIONAL_LNKDIRS "")
438 set(X86_CPUS x86 x86_64 i686)
440 message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
443 message(STATUS "Apple device detected.")
444 set(ADDITIONAL_SRC ${PM3_ROOT}/client/src/util_darwin.h ${PM3_ROOT}/client/src/util_darwin.m ${ADDITIONAL_SRC})
446 find_library(UIKIT_LIBRARY UIKit)
447 if (NOT UIKIT_LIBRARY)
448 message(STATUS "UIKit.framework NOT found!")
450 message(STATUS "UIKit.framework found! ${UIKIT_LIBRARY}")
451 set(ADDITIONAL_LNK "-framework Foundation" "-framework UIKit")
454 find_library(APPKIT_LIBRARY AppKit)
455 if (NOT APPKIT_LIBRARY)
456 message(STATUS "AppKit.framework NOT found!")
458 message(STATUS "AppKit.framework found! ${APPKIT_LIBRARY}")
459 set(ADDITIONAL_LNK "-framework Foundation" "-framework AppKit")
463 if ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
464 set(CMAKE_AUTOMOC ON)
465 set(CMAKE_AUTORCC ON)
466 set(CMAKE_AUTOUIC ON)
468 ${PM3_ROOT}/client/src/proxgui.cpp
469 ${PM3_ROOT}/client/src/proxguiqt.cpp
472 add_definitions("-DHAVE_GUI")
473 set(ADDITIONAL_LNK ${Qt5_LIBRARIES} ${ADDITIONAL_LNK})
474 else ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
476 ${PM3_ROOT}/client/src/guidummy.cpp
478 endif ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
480 if (NOT SKIPBT EQUAL 1)
482 add_definitions("-DHAVE_BLUEZ")
483 set(ADDITIONAL_LNK ${BLUEZ_LIBRARIES} ${ADDITIONAL_LNK})
485 endif(NOT SKIPBT EQUAL 1)
488 set(ADDITIONAL_DIRS ${JANSSON_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
489 set(ADDITIONAL_LNK ${JANSSON_LIBRARIES} ${ADDITIONAL_LNK})
490 endif (JANSSON_FOUND)
492 if (NOT SKIPPYTHON EQUAL 1)
493 if (PYTHON3EMBED_FOUND)
494 add_definitions(-DHAVE_PYTHON)
495 set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
496 set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
497 set(ADDITIONAL_LNKDIRS ${PYTHON3EMBED_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
498 elseif (PYTHON3_FOUND)
499 add_definitions(-DHAVE_PYTHON)
500 set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
501 set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
502 set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
503 endif (PYTHON3EMBED_FOUND)
504 endif (NOT SKIPPYTHON EQUAL 1)
506 if (NOT SKIPREADLINE EQUAL 1)
508 add_definitions("-DHAVE_READLINE")
509 set(ADDITIONAL_DIRS ${READLINE_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
510 set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK})
511 endif (READLINE_FOUND)
512 endif(NOT SKIPREADLINE EQUAL 1)
515 set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
516 set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK})
520 set(ADDITIONAL_DIRS ${LZ4_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
521 set(ADDITIONAL_LNK ${LZ4_LIBRARIES} ${ADDITIONAL_LNK})
524 if (NOT SKIPGD EQUAL 1 AND GD_FOUND)
525 set(ADDITIONAL_DIRS ${GD_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
526 set(ADDITIONAL_LNK ${GD_LIBRARIES} ${ADDITIONAL_LNK})
527 set(ADDITIONAL_LNKDIRS ${GD_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
529 ${PM3_ROOT}/client/src/imgutils.c
530 ${PM3_ROOT}/client/src/cmdhfwaveshare.c
532 add_definitions("-DHAVE_GD")
533 endif (NOT SKIPGD EQUAL 1 AND GD_FOUND)
536 set(ADDITIONAL_DIRS ${WHEREAMI_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
537 set(ADDITIONAL_LNK ${WHEREAMI_LIBRARIES} ${ADDITIONAL_LNK})
538 endif (WHEREAMI_FOUND)
540 message(STATUS "===================================================================")
542 COMMAND sh ${PM3_ROOT}/tools/mkversion.sh --short
543 OUTPUT_VARIABLE version_pm3
545 string(STRIP ${version_pm3} version_pm3)
546 message(STATUS "Version info: ${version_pm3}")
548 message(STATUS "GUI support: skipped")
549 else (SKIPQT EQUAL 1)
551 message(STATUS "GUI support: QT5 found, enabled")
553 message(STATUS "GUI support: QT5 not found, disabled")
555 endif (SKIPQT EQUAL 1)
558 message(STATUS "native BT support: skipped")
559 else (SKIPBT EQUAL 1)
561 message(STATUS "native BT support: Bluez found, enabled")
563 message(STATUS "native BT support: Bluez not found, disabled")
565 endif(SKIPBT EQUAL 1)
569 message(STATUS "Bzip2 library: embedded")
571 message(STATUS "Bzip2 library: system library found")
574 message(SEND_ERROR "Bzip2 library: Bzip2 not found")
579 message(STATUS "LZ4 library: embedded")
581 message(STATUS "LZ4 library: system library found")
584 message(SEND_ERROR "LZ4 library: LZ4 not found")
588 message(STATUS "GD library: skipped")
591 message(STATUS "GD library: embedded")
593 message(STATUS "GD library: system library found")
595 else (SKIPGD EQUAL 1)
596 message(STATUS "GD library: GD not found, disabled")
597 endif (SKIPGD EQUAL 1)
599 if (SKIPJANSSONSYSTEM EQUAL 1)
600 message(STATUS "Jansson library: local library forced")
601 else (SKIPJANSSONSYSTEM EQUAL 1)
603 message(STATUS "Jansson library: system library found")
605 message(STATUS "Jansson library: system library not found, using local library")
606 endif (JANSSON_FOUND)
607 endif (SKIPJANSSONSYSTEM EQUAL 1)
609 if (SKIPPYTHON EQUAL 1)
610 message(STATUS "Python3 library: skipped")
611 else (SKIPPYTHON EQUAL 1)
612 if (PYTHON3EMBED_FOUND)
613 message(STATUS "Python3 library: Python3 embed found, enabled")
614 elseif (PYTHON3_FOUND)
615 message(STATUS "Python3 library: Python3 found, enabled")
616 else (PYTHON3EMBED_FOUND)
617 message(STATUS "Python3 library: Python3 not found, disabled")
618 endif (PYTHON3EMBED_FOUND)
619 endif(SKIPPYTHON EQUAL 1)
621 if (SKIPREADLINE EQUAL 1)
622 message(STATUS "Readline library: skipped")
623 else (SKIPREADLINE EQUAL 1)
626 message(STATUS "Readline library: embedded")
627 else (EMBED_READLINE)
628 message(STATUS "Readline library: system library found")
629 endif (EMBED_READLINE)
630 else (READLINE_FOUND)
631 message(STATUS "Readline library: Readline not found, disabled")
632 endif (READLINE_FOUND)
633 endif(SKIPREADLINE EQUAL 1)
635 if (NOT READLINE_FOUND)
636 if (SKIPLINENOISE EQUAL 1)
637 message(STATUS "Linenoise library: skipped")
638 else (SKIPLINENOISE EQUAL 1)
639 if (LINENOISE_LOCAL_FOUND)
640 message(STATUS "Linenoise library: enabled")
641 else (LINENOISE_LOCAL_FOUND)
642 message(STATUS "Linenoise library: Linenoise not found, disabled")
643 endif (LINENOISE_LOCAL_FOUND)
644 endif (SKIPLINENOISE EQUAL 1)
645 endif (NOT READLINE_FOUND)
647 if (SKIPWHEREAMISYSTEM EQUAL 1)
648 message(STATUS "Whereami library: local library forced")
649 else (SKIPWHEREAMISYSTEM EQUAL 1)
651 message(STATUS "Whereami library: system library found")
652 else (WHEREAMI_FOUND)
653 message(STATUS "Whereami library: system library not found, using local library")
654 endif (WHEREAMI_FOUND)
655 endif (SKIPWHEREAMISYSTEM EQUAL 1)
658 if (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
660 ${PM3_ROOT}/client/src/pm3_luawrap.c
662 add_definitions(-DHAVE_LUA_SWIG)
663 message(STATUS "Lua SWIG: wrapper found")
664 endif (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
667 if (NOT SKIPPYTHON EQUAL 1)
668 if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
669 if (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
671 ${PM3_ROOT}/client/src/pm3_pywrap.c
673 add_definitions(-DHAVE_PYTHON_SWIG)
674 message(STATUS "Python SWIG: wrapper found")
675 endif (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
676 endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
677 endif (NOT SKIPPYTHON EQUAL 1)
678 message(STATUS "===================================================================")
680 add_definitions(-DHAVE_SNPRINTF)
682 add_executable(proxmark3
683 ${PM3_ROOT}/client/src/proxmark3.c
688 target_compile_options(proxmark3 PUBLIC -Wall -Werror -O3)
690 if (NOT SKIPREADLINE EQUAL 1)
691 add_dependencies(proxmark3 ncurses readline)
692 endif (NOT SKIPREADLINE EQUAL 1)
693 endif (EMBED_READLINE)
695 add_dependencies(proxmark3 bzip2)
698 add_dependencies(proxmark3 lz4)
702 # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
703 # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
704 # FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
705 # but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
706 target_compile_definitions(proxmark3 PRIVATE _ISOC99_SOURCE)
708 set(CMAKE_C_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_C_FLAGS}")
709 set(CMAKE_CXX_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_CXX_FLAGS}")
712 set(ADDITIONAL_LNK ws2_32 ${ADDITIONAL_LNK})
715 # GCC 10 has issues with false positives on stringop-overflow,
716 # 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)
717 # beware these flags didn't exist for GCC < 7
718 if(CMAKE_COMPILER_IS_GNUCXX)
719 execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
720 if (GCC_VERSION VERSION_GREATER 10.0 OR GCC_VERSION VERSION_EQUAL 10.0)
721 set(CMAKE_C_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_C_FLAGS}")
722 set(CMAKE_CXX_FLAGS "-Wno-stringop-overflow -Wno-error=stringop-overflow ${CMAKE_CXX_FLAGS}")
724 endif(CMAKE_COMPILER_IS_GNUCXX)
726 target_include_directories(proxmark3 PRIVATE
728 ${PM3_ROOT}/common_fpga
730 ${PM3_ROOT}/client/src
731 ${PM3_ROOT}/client/include
736 # required for Raspberry Pi, but breaks with clang (OSX). Need to be at the end of the linker line.
737 set(ADDITIONAL_LNK ${ADDITIONAL_LNK} -Wl,--as-needed -latomic -Wl,--no-as-needed)
739 #set_property(TARGET proxmark3 PROPERTY LINK_FLAGS "-Wl,-undefined dynamic_lookup")
740 set(ADDITIONAL_LNK ${ADDITIONAL_LNK} -Wl,-undefined,dynamic_lookup)
743 if (NOT JANSSON_FOUND)
744 set(ADDITIONAL_LNK pm3rrg_rdv4_jansson ${ADDITIONAL_LNK})
745 endif (NOT JANSSON_FOUND)
747 if (NOT READLINE_FOUND)
748 if (LINENOISE_LOCAL_FOUND)
749 add_definitions("-DHAVE_LINENOISE")
750 set(ADDITIONAL_LNK pm3rrg_rdv4_linenoise ${ADDITIONAL_LNK})
751 endif (LINENOISE_LOCAL_FOUND)
752 endif (NOT READLINE_FOUND)
754 if (NOT WHEREAMI_FOUND)
755 set(ADDITIONAL_LNK pm3rrg_rdv4_whereami ${ADDITIONAL_LNK})
756 endif (NOT WHEREAMI_FOUND)
758 target_link_libraries(proxmark3 PRIVATE
761 pm3rrg_rdv4_cliparser
766 pm3rrg_rdv4_hardnested
770 if (NOT SKIPPTHREAD EQUAL 1)
771 target_link_libraries(proxmark3 PRIVATE pthread)
772 endif (NOT SKIPPTHREAD EQUAL 1)
774 if (NOT SKIPPYTHON EQUAL 1)
775 # OSX have a hard time compiling python3 dependency with older cmake.
776 if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
777 if (CMAKE_VERSION VERSION_LESS 3.13)
778 message( SEND_ERROR "Your CMAKE version is too old for Apple platform, please update to a version >=3.13" )
779 endif (CMAKE_VERSION VERSION_LESS 3.13)
780 endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
781 endif (NOT SKIPPYTHON EQUAL 1)
783 target_link_directories(proxmark3 PRIVATE ${ADDITIONAL_LNKDIRS})
785 install(TARGETS proxmark3 DESTINATION "bin")
786 install(DIRECTORY cmdscripts lualibs luascripts pyscripts resources dictionaries DESTINATION "share/proxmark3")
788 add_custom_command(OUTPUT lualibs/pm3_cmd.lua
789 COMMAND "awk -f pm3_cmd_h2lua.awk ../include/pm3_cmd.h > lualibs/pm3_cmd.lua"
790 COMMENT "Creating lualibs/pm3_cmd.lua"
793 add_custom_command(OUTPUT lualibs/mfc_default_keys.lua
794 COMMAND "awk -f default_keys_dic2lua.awk mfc_default_keys.dic > lualibs/mfc_default_keys.lua"
795 COMMENT "Creating lualibs/mfc_default_keys.lua"
798 #"make package" will trigger this
799 SET(CPACK_GENERATOR "DEB")
800 SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Iceman")