4 # cmake .. (see below for options)
5 # make (VERBOSE=1 if needed)
9 # cmake -G"MSYS Makefiles" ..
10 # On Proxspace 3.3 or less, you need to install cmake:
11 # pacman -S mingw-w64-x86_64-cmake
12 # /mingw64/bin/cmake -G"MSYS Makefiles" ..
14 # Android cross-compilation: (ANDROID_ABI=arm64-v8a for a 64b version)
16 # -DCMAKE_TOOLCHAIN_FILE=<path-to-your-android-ndk>/build/cmake/android.toolchain.cmake \
17 # -DANDROID_ABI=armeabi-v7a \
18 # -DANDROID_NATIVE_API_LEVEL=android-19 \
19 # -DSKIPBT=1 -DSKIPPYTHON=1 -DSKIPPTHREAD=1 ..
21 message(STATUS "CMake ${CMAKE_VERSION}")
22 cmake_minimum_required(VERSION 3.10)
24 SET (PM3_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
26 if(CMAKE_VERSION VERSION_LESS "3.7.0")
27 set(CMAKE_INCLUDE_CURRENT_DIR ON)
30 find_package(PkgConfig)
32 if (NOT SKIPQT EQUAL 1)
33 if(APPLE AND EXISTS /usr/local/opt/qt5)
34 # Homebrew installs Qt5 (up to at least 5.11.0) in
35 # /usr/local/opt/qt5. Ensure that it can be found by CMake
36 # since it is not in the default /usr/local prefix.
37 # Add it to PATHS so that it doesn't override the
38 # CMAKE_PREFIX_PATH environment variable.
39 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
40 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
41 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /usr/local/opt/qt5)
42 endif(APPLE AND EXISTS /usr/local/opt/qt5)
43 if(APPLE AND EXISTS /opt/homebrew/opt/qt5)
44 # Homebrew on Apple Silicon installs Qt5 in
45 # /opt/homebrew/opt/qt5. Ensure that it can be found by CMake
46 # since it is not in the default /usr/local prefix.
47 # Add it to PATHS so that it doesn't override the
48 # CMAKE_PREFIX_PATH environment variable.
49 # QT_FIND_PACKAGE_OPTIONS should be passed to find_package,
50 # e.g. find_package(Qt5Core ${QT_FIND_PACKAGE_OPTIONS})
51 list(APPEND QT_FIND_PACKAGE_OPTIONS PATHS /opt/homebrew/opt/qt5)
52 endif(APPLE AND EXISTS /opt/homebrew/opt/qt5)
59 foreach(_qt_package IN LISTS QT_PACKAGELIST)
60 find_package(${_qt_package} QUIET ${QT_FIND_PACKAGE_OPTIONS})
61 set(Qt5_LIBRARIES ${${_qt_package}_LIBRARIES} ${Qt5_LIBRARIES})
62 if(NOT ${_qt_package}_FOUND)
64 endif(NOT ${_qt_package}_FOUND)
66 endif (NOT SKIPQT EQUAL 1)
68 if (NOT SKIPBT EQUAL 1)
69 pkg_search_module(BLUEZ QUIET bluez)
70 endif (NOT SKIPBT EQUAL 1)
72 if (NOT SKIPPYTHON EQUAL 1)
73 pkg_search_module(PYTHON3 QUIET python3)
74 pkg_search_module(PYTHON3EMBED QUIET python3-embed)
75 endif (NOT SKIPPYTHON EQUAL 1)
77 # If cross-compiled, we need to init source and build.
78 if (CMAKE_TOOLCHAIN_FILE)
79 set(CFLAGS_EXTERNAL_LIB "CFLAGS=--target=${CMAKE_C_COMPILER_TARGET} -w")
80 set(EMBED_READLINE ON)
82 endif (CMAKE_TOOLCHAIN_FILE)
84 if (EMBED_READLINE OR EMBED_BZIP2)
85 include(ExternalProject)
86 endif (EMBED_READLINE OR EMBED_BZIP2)
88 if (NOT SKIPREADLINE EQUAL 1)
90 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)
91 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)
94 ExternalProject_Add(ncurses
95 URL http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
97 DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/ncurses
98 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
100 BUILD_COMMAND make libs
104 ExternalProject_Add_StepTargets(ncurses configure build install)
106 ExternalProject_Add(readline
107 URL ftp://ftp.gnu.org/gnu/readline/readline-8.1.tar.gz
109 DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/readline
110 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
116 ExternalProject_Add_StepTargets(readline configure build install)
117 set(READLINE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/)
118 set(READLINE_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/readline/src/readline/libreadline.a ${CMAKE_CURRENT_BINARY_DIR}/deps/ncurses/src/ncurses/lib/libtinfo.a)
119 else (EMBED_READLINE)
120 find_path(READLINE_INCLUDE_DIRS readline/readline.h)
121 find_library(READLINE_LIBRARIES readline)
122 endif (EMBED_READLINE)
123 if (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
124 set(READLINE_FOUND ON)
125 endif (READLINE_INCLUDE_DIRS AND READLINE_LIBRARIES)
126 endif (NOT SKIPREADLINE EQUAL 1)
128 if (NOT SKIPJANSSONSYSTEM EQUAL 1)
129 pkg_check_modules(PC_JANSSON QUIET jansson)
130 find_path(JANSSON_INCLUDE_DIRS
132 HINTS ${PC_JANSSON_INCLUDEDIR} ${PC_JANSSON_INCLUDE_DIRS})
133 find_library(JANSSON_LIBRARIES
134 NAMES jansson libjansson
135 HINTS ${PC_JANSSON_LIBDIR} ${PC_JANSSON_LIBRARY_DIRS})
136 if (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
137 set(JANSSON_FOUND ON)
138 endif (JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARIES)
139 endif (NOT SKIPJANSSONSYSTEM EQUAL 1)
142 set(BZIP2_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
143 ExternalProject_Add(bzip2
144 GIT_REPOSITORY https://android.googlesource.com/platform/external/bzip2
145 GIT_TAG platform-tools-30.0.2
147 SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/bzip2
148 CONFIGURE_COMMAND mkdir -p ${BZIP2_BUILD_DIR} && git archive --format tar HEAD | tar -C ${BZIP2_BUILD_DIR} -x
150 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
154 ExternalProject_Add_StepTargets(bzip2 configure build install)
155 set(BZIP2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2)
156 set(BZIP2_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/deps/bzip2/src/bzip2/libbz2.a)
159 find_package (BZip2 REQUIRED)
162 if (NOT SKIPWHEREAMISYSTEM EQUAL 1)
163 find_path(WHEREAMI_INCLUDE_DIRS whereami.h)
164 find_library(WHEREAMI_LIBRARIES whereami)
165 if (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
166 set(WHEREAMI_FOUND ON)
167 endif (WHEREAMI_INCLUDE_DIRS AND WHEREAMI_LIBRARIES)
168 endif (NOT SKIPWHEREAMISYSTEM EQUAL 1)
170 add_subdirectory(${PM3_ROOT}/client/deps deps)
173 ${PM3_ROOT}/common/commonutil.c
174 ${PM3_ROOT}/common/util_posix.c
175 ${PM3_ROOT}/common/parity.c
176 ${PM3_ROOT}/common/bucketsort.c
177 ${PM3_ROOT}/common/crapto1/crapto1.c
178 ${PM3_ROOT}/common/crapto1/crypto1.c
179 ${PM3_ROOT}/common/crc.c
180 ${PM3_ROOT}/common/crc16.c
181 ${PM3_ROOT}/common/crc32.c
182 ${PM3_ROOT}/common/crc64.c
183 ${PM3_ROOT}/common/lfdemod.c
184 ${PM3_ROOT}/common/legic_prng.c
185 ${PM3_ROOT}/common/iso15693tools.c
186 ${PM3_ROOT}/common/cardhelper.c
187 ${PM3_ROOT}/common/generator.c
188 ${PM3_ROOT}/client/src/crypto/asn1dump.c
189 ${PM3_ROOT}/client/src/crypto/asn1utils.c
190 ${PM3_ROOT}/client/src/crypto/libpcrypto.c
191 ${PM3_ROOT}/client/src/emv/test/cda_test.c
192 ${PM3_ROOT}/client/src/emv/test/crypto_test.c
193 ${PM3_ROOT}/client/src/emv/test/cryptotest.c
194 ${PM3_ROOT}/client/src/emv/test/dda_test.c
195 ${PM3_ROOT}/client/src/emv/test/sda_test.c
196 ${PM3_ROOT}/client/src/emv/cmdemv.c
197 ${PM3_ROOT}/client/src/emv/crypto.c
198 ${PM3_ROOT}/client/src/emv/crypto_polarssl.c
199 ${PM3_ROOT}/client/src/emv/dol.c
200 ${PM3_ROOT}/client/src/emv/emv_pk.c
201 ${PM3_ROOT}/client/src/emv/emv_pki.c
202 ${PM3_ROOT}/client/src/emv/emv_pki_priv.c
203 ${PM3_ROOT}/client/src/emv/emv_roca.c
204 ${PM3_ROOT}/client/src/emv/emv_tags.c
205 ${PM3_ROOT}/client/src/emv/emvcore.c
206 ${PM3_ROOT}/client/src/emv/emvjson.c
207 ${PM3_ROOT}/client/src/emv/tlv.c
208 ${PM3_ROOT}/client/src/fido/additional_ca.c
209 ${PM3_ROOT}/client/src/fido/cbortools.c
210 ${PM3_ROOT}/client/src/fido/cose.c
211 ${PM3_ROOT}/client/src/fido/fidocore.c
212 ${PM3_ROOT}/client/src/iso7816/apduinfo.c
213 ${PM3_ROOT}/client/src/iso7816/iso7816core.c
214 ${PM3_ROOT}/client/src/cipurse/cipursecrypto.c
215 ${PM3_ROOT}/client/src/cipurse/cipursecore.c
216 ${PM3_ROOT}/client/src/cipurse/cipursetest.c
217 ${PM3_ROOT}/client/src/loclass/cipher.c
218 ${PM3_ROOT}/client/src/loclass/cipherutils.c
219 ${PM3_ROOT}/client/src/loclass/elite_crack.c
220 ${PM3_ROOT}/client/src/loclass/hash1_brute.c
221 ${PM3_ROOT}/client/src/loclass/ikeys.c
222 ${PM3_ROOT}/client/src/mifare/mad.c
223 ${PM3_ROOT}/client/src/mifare/mfkey.c
224 ${PM3_ROOT}/client/src/mifare/mifare4.c
225 ${PM3_ROOT}/client/src/mifare/mifaredefault.c
226 ${PM3_ROOT}/client/src/mifare/mifarehost.c
227 ${PM3_ROOT}/client/src/nfc/ndef.c
228 ${PM3_ROOT}/client/src/mifare/desfire_crypto.c
229 ${PM3_ROOT}/client/src/uart/uart_posix.c
230 ${PM3_ROOT}/client/src/uart/uart_win32.c
231 ${PM3_ROOT}/client/src/ui/overlays.ui
232 ${PM3_ROOT}/client/src/aiddesfire.c
233 ${PM3_ROOT}/client/src/aidsearch.c
234 ${PM3_ROOT}/client/src/cmdanalyse.c
235 ${PM3_ROOT}/client/src/cmdcrc.c
236 ${PM3_ROOT}/client/src/cmddata.c
237 ${PM3_ROOT}/client/src/cmdflashmem.c
238 ${PM3_ROOT}/client/src/cmdflashmemspiffs.c
239 ${PM3_ROOT}/client/src/cmdhf.c
240 ${PM3_ROOT}/client/src/cmdhf14a.c
241 ${PM3_ROOT}/client/src/cmdhf14b.c
242 ${PM3_ROOT}/client/src/cmdhf15.c
243 ${PM3_ROOT}/client/src/cmdhfcryptorf.c
244 ${PM3_ROOT}/client/src/cmdhfemrtd.c
245 ${PM3_ROOT}/client/src/cmdhfepa.c
246 ${PM3_ROOT}/client/src/cmdhffelica.c
247 ${PM3_ROOT}/client/src/cmdhffido.c
248 ${PM3_ROOT}/client/src/cmdhfcipurse.c
249 ${PM3_ROOT}/client/src/cmdhficlass.c
250 ${PM3_ROOT}/client/src/cmdhfjooki.c
251 ${PM3_ROOT}/client/src/cmdhflegic.c
252 ${PM3_ROOT}/client/src/cmdhflist.c
253 ${PM3_ROOT}/client/src/cmdhflto.c
254 ${PM3_ROOT}/client/src/cmdhfmf.c
255 ${PM3_ROOT}/client/src/cmdhfmfdes.c
256 ${PM3_ROOT}/client/src/cmdhfmfhard.c
257 ${PM3_ROOT}/client/src/cmdhfmfp.c
258 ${PM3_ROOT}/client/src/cmdhfmfu.c
259 ${PM3_ROOT}/client/src/cmdhfseos.c
260 ${PM3_ROOT}/client/src/cmdhfst.c
261 ${PM3_ROOT}/client/src/cmdhfst25ta.c
262 ${PM3_ROOT}/client/src/cmdhfthinfilm.c
263 ${PM3_ROOT}/client/src/cmdhftopaz.c
264 ${PM3_ROOT}/client/src/cmdhfwaveshare.c
265 ${PM3_ROOT}/client/src/cmdhw.c
266 ${PM3_ROOT}/client/src/cmdlf.c
267 ${PM3_ROOT}/client/src/cmdlfawid.c
268 ${PM3_ROOT}/client/src/cmdlfcotag.c
269 ${PM3_ROOT}/client/src/cmdlfdestron.c
270 ${PM3_ROOT}/client/src/cmdlfem.c
271 ${PM3_ROOT}/client/src/cmdlfem410x.c
272 ${PM3_ROOT}/client/src/cmdlfem4x05.c
273 ${PM3_ROOT}/client/src/cmdlfem4x50.c
274 ${PM3_ROOT}/client/src/cmdlfem4x70.c
275 ${PM3_ROOT}/client/src/cmdlffdxb.c
276 ${PM3_ROOT}/client/src/cmdlfgallagher.c
277 ${PM3_ROOT}/client/src/cmdlfguard.c
278 ${PM3_ROOT}/client/src/cmdlfhid.c
279 ${PM3_ROOT}/client/src/cmdlfhitag.c
280 ${PM3_ROOT}/client/src/cmdlfidteck.c
281 ${PM3_ROOT}/client/src/cmdlfindala.c
282 ${PM3_ROOT}/client/src/cmdlfio.c
283 ${PM3_ROOT}/client/src/cmdlfjablotron.c
284 ${PM3_ROOT}/client/src/cmdlfkeri.c
285 ${PM3_ROOT}/client/src/cmdlfmotorola.c
286 ${PM3_ROOT}/client/src/cmdlfnedap.c
287 ${PM3_ROOT}/client/src/cmdlfnexwatch.c
288 ${PM3_ROOT}/client/src/cmdlfnoralsy.c
289 ${PM3_ROOT}/client/src/cmdlfpac.c
290 ${PM3_ROOT}/client/src/cmdlfparadox.c
291 ${PM3_ROOT}/client/src/cmdlfpcf7931.c
292 ${PM3_ROOT}/client/src/cmdlfpresco.c
293 ${PM3_ROOT}/client/src/cmdlfpyramid.c
294 ${PM3_ROOT}/client/src/cmdlfsecurakey.c
295 ${PM3_ROOT}/client/src/cmdlft55xx.c
296 ${PM3_ROOT}/client/src/cmdlfti.c
297 ${PM3_ROOT}/client/src/cmdlfviking.c
298 ${PM3_ROOT}/client/src/cmdlfvisa2000.c
299 ${PM3_ROOT}/client/src/cmdmain.c
300 ${PM3_ROOT}/client/src/cmdnfc.c
301 ${PM3_ROOT}/client/src/cmdparser.c
302 ${PM3_ROOT}/client/src/cmdscript.c
303 ${PM3_ROOT}/client/src/cmdsmartcard.c
304 ${PM3_ROOT}/client/src/cmdtrace.c
305 ${PM3_ROOT}/client/src/cmdusart.c
306 ${PM3_ROOT}/client/src/cmdwiegand.c
307 ${PM3_ROOT}/client/src/comms.c
308 ${PM3_ROOT}/client/src/fileutils.c
309 ${PM3_ROOT}/client/src/flash.c
310 ${PM3_ROOT}/client/src/graph.c
311 ${PM3_ROOT}/client/src/jansson_path.c
312 ${PM3_ROOT}/client/src/preferences.c
313 ${PM3_ROOT}/client/src/pm3.c
314 ${PM3_ROOT}/client/src/pm3_binlib.c
315 ${PM3_ROOT}/client/src/pm3_bitlib.c
316 ${PM3_ROOT}/client/src/prng.c
317 ${PM3_ROOT}/client/src/scandir.c
318 ${PM3_ROOT}/client/src/scripting.c
319 ${PM3_ROOT}/client/src/tea.c
320 ${PM3_ROOT}/client/src/ui.c
321 ${PM3_ROOT}/client/src/util.c
322 ${PM3_ROOT}/client/src/wiegand_formats.c
323 ${PM3_ROOT}/client/src/wiegand_formatutils.c
324 ${CMAKE_BINARY_DIR}/version_pm3.c
328 OUTPUT ${CMAKE_BINARY_DIR}/version_pm3.c
329 COMMAND ${CMAKE_COMMAND} -E copy ${PM3_ROOT}/common/default_version_pm3.c ${CMAKE_BINARY_DIR}/version_pm3.c
330 DEPENDS ${PM3_ROOT}/common/default_version_pm3.c
333 set(ADDITIONAL_SRC "")
334 set(ADDITIONAL_LNK "")
335 set(ADDITIONAL_DIRS "")
336 set(ADDITIONAL_LNKDIRS "")
337 set(X86_CPUS x86 x86_64 i686)
339 message(STATUS "CMAKE_SYSTEM_PROCESSOR := ${CMAKE_SYSTEM_PROCESSOR}")
342 message(STATUS "Apple device detected.")
343 set(ADDITIONAL_SRC ${PM3_ROOT}/client/src/util_darwin.h ${PM3_ROOT}/client/src/util_darwin.m ${ADDITIONAL_SRC})
344 set(ADDITIONAL_LNK "-framework Foundation" "-framework AppKit")
347 if ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
348 set(CMAKE_AUTOMOC ON)
349 set(CMAKE_AUTORCC ON)
350 set(CMAKE_AUTOUIC ON)
352 ${PM3_ROOT}/client/src/proxgui.cpp
353 ${PM3_ROOT}/client/src/proxguiqt.cpp
356 add_definitions("-DHAVE_GUI")
357 set(ADDITIONAL_LNK ${Qt5_LIBRARIES} ${ADDITIONAL_LNK})
358 else ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
360 ${PM3_ROOT}/client/src/guidummy.cpp
362 endif ((NOT SKIPQT EQUAL 1) AND (Qt5_FOUND))
364 if (NOT SKIPBT EQUAL 1)
366 add_definitions("-DHAVE_BLUEZ")
367 set(ADDITIONAL_LNK ${BLUEZ_LIBRARIES} ${ADDITIONAL_LNK})
369 endif(NOT SKIPBT EQUAL 1)
372 set(ADDITIONAL_DIRS ${JANSSON_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
373 set(ADDITIONAL_LNK ${JANSSON_LIBRARIES} ${ADDITIONAL_LNK})
374 endif (JANSSON_FOUND)
376 if (NOT SKIPPYTHON EQUAL 1)
377 if (PYTHON3EMBED_FOUND)
378 add_definitions(-DHAVE_PYTHON)
379 set(ADDITIONAL_DIRS ${PYTHON3EMBED_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
380 set(ADDITIONAL_LNK ${PYTHON3EMBED_LIBRARIES} ${ADDITIONAL_LNK})
381 set(ADDITIONAL_LNKDIRS ${PYTHON3EMBED_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
382 elseif (PYTHON3_FOUND)
383 add_definitions(-DHAVE_PYTHON)
384 set(ADDITIONAL_DIRS ${PYTHON3_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
385 set(ADDITIONAL_LNK ${PYTHON3_LIBRARIES} ${ADDITIONAL_LNK})
386 set(ADDITIONAL_LNKDIRS ${PYTHON3_LIBRARY_DIRS} ${ADDITIONAL_LNKDIRS})
387 endif (PYTHON3EMBED_FOUND)
388 endif (NOT SKIPPYTHON EQUAL 1)
390 if (NOT SKIPREADLINE EQUAL 1)
392 add_definitions("-DHAVE_READLINE")
393 set(ADDITIONAL_DIRS ${READLINE_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
394 set(ADDITIONAL_LNK ${READLINE_LIBRARIES} ${ADDITIONAL_LNK})
395 endif (READLINE_FOUND)
396 endif(NOT SKIPREADLINE EQUAL 1)
399 set(ADDITIONAL_DIRS ${BZIP2_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
400 set(ADDITIONAL_LNK ${BZIP2_LIBRARIES} ${ADDITIONAL_LNK})
404 set(ADDITIONAL_DIRS ${WHEREAMI_INCLUDE_DIRS} ${ADDITIONAL_DIRS})
405 set(ADDITIONAL_LNK ${WHEREAMI_LIBRARIES} ${ADDITIONAL_LNK})
406 endif (WHEREAMI_FOUND)
408 message(STATUS "===================================================================")
410 message(STATUS "GUI support: skipped")
411 else (SKIPQT EQUAL 1)
413 message(STATUS "GUI support: QT5 found, enabled")
415 message(STATUS "GUI support: QT5 not found, disabled")
417 endif (SKIPQT EQUAL 1)
420 message(STATUS "native BT support: skipped")
421 else (SKIPBT EQUAL 1)
423 message(STATUS "native BT support: Bluez found, enabled")
425 message(STATUS "native BT support: Bluez not found, disabled")
427 endif(SKIPBT EQUAL 1)
430 message(STATUS "Bzip2 library: embedded")
432 message(STATUS "Bzip2 library: system library found")
435 if (SKIPJANSSONSYSTEM EQUAL 1)
436 message(STATUS "Jansson library: local library forced")
437 else (SKIPJANSSONSYSTEM EQUAL 1)
439 message(STATUS "Jansson library: system library found")
441 message(STATUS "Jansson library: system library not found, using local library")
442 endif (JANSSON_FOUND)
443 endif (SKIPJANSSONSYSTEM EQUAL 1)
445 if (SKIPPYTHON EQUAL 1)
446 message(STATUS "Python3 library: skipped")
447 else (SKIPPYTHON EQUAL 1)
448 if (PYTHON3EMBED_FOUND)
449 message(STATUS "Python3 library: Python3 embed found, enabled")
450 elseif (PYTHON3_FOUND)
451 message(STATUS "Python3 library: Python3 found, enabled")
452 else (PYTHON3EMBED_FOUND)
453 message(STATUS "Python3 library: Python3 not found, disabled")
454 endif (PYTHON3EMBED_FOUND)
455 endif(SKIPPYTHON EQUAL 1)
457 if (SKIPREADLINE EQUAL 1)
458 message(STATUS "Readline library: skipped")
459 else (SKIPREADLINE EQUAL 1)
462 message(STATUS "Readline library: embedded")
463 else (EMBED_READLINE)
464 message(STATUS "Readline library: system library found")
465 endif (EMBED_READLINE)
466 else (READLINE_FOUND)
467 message(STATUS "Readline library: Readline not found, disabled")
468 endif (READLINE_FOUND)
469 endif(SKIPREADLINE EQUAL 1)
471 if (SKIPWHEREAMISYSTEM EQUAL 1)
472 message(STATUS "Whereami library: local library forced")
473 else (SKIPWHEREAMISYSTEM EQUAL 1)
475 message(STATUS "Whereami library: system library found")
476 else (WHEREAMI_FOUND)
477 message(STATUS "Whereami library: system library not found, using local library")
478 endif (WHEREAMI_FOUND)
479 endif (SKIPWHEREAMISYSTEM EQUAL 1)
482 if (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
484 ${PM3_ROOT}/client/src/pm3_luawrap.c
486 add_definitions(-DHAVE_LUA_SWIG)
487 message(STATUS "Lua SWIG: wrapper found")
488 endif (EXISTS ${PM3_ROOT}/client/src/pm3_luawrap.c)
491 if (NOT SKIPPYTHON EQUAL 1)
492 if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
493 if (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
495 ${PM3_ROOT}/client/src/pm3_pywrap.c
497 add_definitions(-DHAVE_PYTHON_SWIG)
498 message(STATUS "Python SWIG: wrapper found")
499 endif (EXISTS ${PM3_ROOT}/client/src/pm3_pywrap.c)
500 endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
501 endif (NOT SKIPPYTHON EQUAL 1)
502 message(STATUS "===================================================================")
504 add_executable(proxmark3
505 ${PM3_ROOT}/client/src/proxmark3.c
510 target_compile_options(proxmark3 PUBLIC -Wall -O3)
512 if (NOT SKIPREADLINE EQUAL 1)
513 add_dependencies(proxmark3 ncurses readline)
514 endif (NOT SKIPREADLINE EQUAL 1)
515 endif (EMBED_READLINE)
517 add_dependencies(proxmark3 bzip2)
521 # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
522 # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
523 # FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
524 # but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
525 target_compile_definitions(proxmark3 PRIVATE _ISOC99_SOURCE)
527 set(CMAKE_C_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_C_FLAGS}")
528 set(CMAKE_CXX_FLAGS "-mno-ms-bitfields -fexec-charset=cp850 ${CMAKE_CXX_FLAGS}")
531 target_include_directories(proxmark3 PRIVATE
533 ${PM3_ROOT}/common_fpga
535 ${PM3_ROOT}/client/src
536 ${PM3_ROOT}/client/include
541 # required for Raspberry Pi, but breaks with clang (OSX). Need to be at the end of the linker line.
542 set(ADDITIONAL_LNK ${ADDITIONAL_LNK} -Wl,--as-needed -latomic -Wl,--no-as-needed)
545 if (NOT JANSSON_FOUND)
546 set(ADDITIONAL_LNK pm3rrg_rdv4_jansson ${ADDITIONAL_LNK})
547 endif (NOT JANSSON_FOUND)
548 if (NOT WHEREAMI_FOUND)
549 set(ADDITIONAL_LNK pm3rrg_rdv4_whereami ${ADDITIONAL_LNK})
550 endif (NOT WHEREAMI_FOUND)
552 target_link_libraries(proxmark3 PRIVATE
555 pm3rrg_rdv4_cliparser
560 pm3rrg_rdv4_hardnested
563 if (NOT SKIPPTHREAD EQUAL 1)
564 target_link_libraries(proxmark3 PRIVATE pthread)
565 endif (NOT SKIPPTHREAD EQUAL 1)
567 if (NOT SKIPPYTHON EQUAL 1)
568 # OSX have a hard time compiling python3 dependency with older cmake.
569 if (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
570 if (NOT CMAKE_VERSION VERSION_LESS 3.13)
571 target_link_directories(proxmark3 PRIVATE ${ADDITIONAL_LNKDIRS})
573 message( SEND_ERROR "Your CMAKE version is too old for Apple platform, please update to a version >=3.13" )
574 endif (NOT CMAKE_VERSION VERSION_LESS 3.13)
575 endif (PYTHON3EMBED_FOUND OR PYTHON3_FOUND)
576 endif (NOT SKIPPYTHON EQUAL 1)
578 install(TARGETS proxmark3 DESTINATION "bin")
579 install(DIRECTORY cmdscripts lualibs luascripts pyscripts resources dictionaries DESTINATION "share/proxmark3")
581 add_custom_command(OUTPUT lualibs/pm3_cmd.lua
582 COMMAND "awk -f pm3_cmd_h2lua.awk ../include/pm3_cmd.h > lualibs/pm3_cmd.lua"
583 COMMENT "Creating lualibs/pm3_cmd.lua"
586 add_custom_command(OUTPUT lualibs/mfc_default_keys.lua
587 COMMAND "awk -f default_keys_dic2lua.awk mfc_default_keys.dic > lualibs/mfc_default_keys.lua"
588 COMMENT "Creating lualibs/mfc_default_keys.lua"
591 #"make package" will trigger this
592 SET(CPACK_GENERATOR "DEB")
593 SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Iceman")